Indent settings
- Autoindent (AI)
Copy indent from current line when starting a new line (typing
In insert mode or when using the "O" or "O" Command). If you do not
Type anything on the new line before T or CTRL-D and then type
CTRL-O or, the indent is deleted again.
Simply put, the indent value of the new line is consistent with that of the previous line.
- Smartindent (SI)
An indent is automatically inserted:
- After a line ending in '{'.
- After a line starting with a keyword from 'cinword '.
- Before a line starting with '}' (only with the "O" command ).
When typing '}' as the first character in a new line, that line is
Given the same indent as the matching '{'.
Based on autoindent, it is more smart: it provides better support for the indentation of {} in programming.
- Cindent (CI)
Enables automatic C program indenting.
Auto indent for C program adaptation. It works with "cinkeys", "cinwords", and "cinoptions" to produce results.
- Indentexpr (INDE)
Expression which is evaluated to obtain the proper indent for a line.
It is used when a new line is created, for the |=| operator and
In insert mode as specified with the 'initkeys 'option.
When this option is not empty, it overrules the 'cindent 'and
'Smartindent 'indenting. When 'lisp 'is set, this option is
Overridden by the lisp indentation algorithm.
More personalized settings for specific indentation. You can also use the indentation settings of lisp ~
- Relationship between the indentation settings
There are in fact four main methods available for indentation, each one
Overrides the previous if it is enabled, or non-empty for 'indentexpr ':
'Autoindent 'uses the indent from the previous line.
'Smartindent 'is like 'autoindent' but also recognizes some C syntax to increase/reduce the indent where appropriate.
'Cindent 'works more cleverly than the other two and is retriable to different indenting styles.
The most flexible of all: Evaluates an expression to compute the indent of a line. When non-empty this method overrides the other ones. See | indent-expression |.
- Paste
After the above xxindent is enabled, the indentation format will be disordered when pasting from other windows to VIM. To avoid this phenomenon, you can enable the paste option to invalidate various indent, retain the indent of the original text. Close it after completion. When the paste option is enabled and the insert mode is switched, the following status bar will prompt: insert (paste)
Indent in VIM