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 select Tab. Select Shift+Tab to decrease the indentation.
Don't detect indentation settings
To turn off the automatic detection of indentation settings, go to Preferences > Text Editor > Behavior and clear Auto detect.
Fix indentation in an open file
To fix the indentation in the file currently open in the editor:
- On the editor toolbar, select Spaces, and then select Auto-indent Selection to automatically indent the selected text using the current settings.
- Go to Edit > Advanced, and select an indentation option or use keyboard shortcuts.
Indentation options
- To automatically indent the highlighted text, select Auto-indent Selection or select Ctrl+I.
- To automatically format the highlighted text, select Auto-format Selection or select Ctrl+;.
- To adjust the wrapping of the selected paragraph, select Rewrap Paragraph or select Ctrl+E followed by R.
- To toggle text wrapping, select Enable Text Wrapping or select Ctrl+E followed by Ctrl+W.
- To visualize whitespace in the editor, select Visualize Whitespace or select Ctrl+E followed by Ctrl+V.
- To clear all whitespace characters from the currently open file, select Clean Whitespace.
Automatically fix indentation upon file save
To automatically fix indentation according to the indentation settings when you save the file, go to Preferences > Text Editor > Behavior > Clean whitespace and select Clean indentation. Select Skip clean whitespace for file types to exclude the specified file types.
Show whitespace in editor
To visualize whitespace in the editor, go to 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 Display right margin at column. To use a different color for the margin area, select Tint whole margin area. Clear it to show the margin as a vertical line.
To use a context-specific margin when available, select Use context-specific margin. 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.
Copyright © The Qt Company Ltd. and other contributors. 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.