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.

{Text Editor Behavior preferences}

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.

{Text Editor Display preferences}

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.

See also Behavior, Qt Quick Code Style, and Keyboard Shortcuts.

Available under certain Qt licenses.
Find out more.