Indent text or code
When you type text or code, it is indented automatically according to the selected text editor or code style preferences. Select a block to indent it when you press Tab. Press Shift+Tab to decrease the indentation. You can disable automatic indentation.
To fix the indentation in the file currently open in the editor, select options in the Edit > Advanced menu or use keyboard shortcuts:
- To automatically indent the highlighted text, select Auto-indent Selection or press Ctrl+I.
- To automatically format the highlighted text, select Auto-format Selection or press Ctrl+;.
- To adjust the wrapping of the selected paragraph, select Rewrap Paragraph or press Ctrl+E followed by R.
- To toggle text wrapping, select Enable Text Wrapping or press Ctrl+E followed by Ctrl+W.
- To visualize whitespace in the editor, select Visualize Whitespace or press Ctrl+E followed by Ctrl+V.
- To clear all whitespace characters from the currently open file, select Clean Whitespace.
Automatically fix indentation
To automatically fix indentation according to the indentation settings when you save the file, select Preferences > Text Editor > Behavior > Clean whitespace > Clean indentation. Select the Skip clean whitespace for file types check box to exclude the specified file types.
Show whitespace in editor
To visualize whitespace in the editor, select Preferences > Text Editor > Display > Visualize whitespace.
To visualize indentation, select Visualize Indent. To adjust the color of the visualization, change the value of the Visual Whitespace setting of the editor color scheme in Font & Colors.
Display right margin
To help you keep line length at a particular number of characters, set the number of characters in the Display right margin at column field. To use a different color for the margin area, select the Tint whole margin area check box. Deselect the check box to show the margin as a vertical line.
To use a context-specific margin when available, select the Use context-specific margin check box. Then, use the ClangFormat ColumnLimit
option to set the margin, for example.
See also C++ Code Style, Behavior, Qt Quick Code Style, and Keyboard Shortcuts.
© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.