By default, the action of the tab key depends on the selected Keyboard Personality, file type, and position within the file as described under Default for Personality below.
To insert a real tab character regardless of the indentation mode or the position of the cursor on a line, type Ctrl-Tab or Ctrl-T.
The behavior of the tab key can be altered using the Tab Key Action preference, which provides the following options:
Default for Personality
This selects from the other tab key actions below according to the chosen keyboard personality, current file type, and in some cases the position of the caret within the file. In all non-Python files, the default is Move to Next Tab Stop. In Python files, the defaults are as follows by keyboard personality:
- Normal: Smart Tab
- VI/VIM: Move to Next Tab Stop
- Emacs: Indent to Match
- Brief: Smart Tab
- Visual Studio: Move to Next Tab Stop
- OS X: Smart Tab
Indent to Match
This indents the current line or selected lines to position them at the computed indent level for their context in the file.
Move to Next Tab Stop
This enters indentation characters matching the current file's style of indentation so that the caret reaches the next tab stop.
This enters indentation characters matching the current file's style of indentation to increase the indentation of the current line or selected lines by one level.
Insert Tab Character
This inserts a Tab character (chr(9)) into the file.
This option is available for Python files only. It implements the following behavior for the tab key:
When the caret is within a line or there is a non-empty selection, this performs Indent to Match. When the line or lines are already at the matching position, indentation is toggled between likely positions as follows:
- If a comment precedes the current line or selection, then indentation will match the position of the prior non-comment code line (if any).
- If multiple nested blocks match an 'else', 'elif', 'except', or 'finally', then indentation will match the position of the enclosing blocks (traversing each in outward order).
- In other cases, indentation is reduced by one level.
- When the caret is at the end of a non-empty line and there is no selection, one indent level is inserted. The Smart Tab End of Line Indents preference can be used to alter the type of indentation used or to disable this aspect of the Smart Tab feature.
|« 4.11.3. Auto-Indent||Table of Contents||4.11.5. Checking Indentation »|