From :h indent.txt
:
...each one overrides the previous if it is enabled...
Now if I set 'cin'
after 'ai'
, Does 'cin'
disable the effect of 'ai'
?.
If no, so what is the purpose of "override" exactly?
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.
Sign up to join this communityFrom :h indent.txt
:
...each one overrides the previous if it is enabled...
Now if I set 'cin'
after 'ai'
, Does 'cin'
disable the effect of 'ai'
?.
If no, so what is the purpose of "override" exactly?
Order does not matter. The override behavior is based on what is currently set/unset, changing one option value does not change others. Additionally, indent.txt
refers to methods not settings, so the behavior is not completely straight-forward since the expression in indentexpr
can itself return "not enabled." The documentation requires some further explanation:
indentexpr
is set, cindent
,smartindent
, and autoindent
will all have no base effect (* caveat 1 applies). Note that for indentexpr
"unset" means set to empty string.cindent
is set and indentexpr
is unset, {smartindent,autoindent}
will have no effect.smartindent
is set and {cindent, indentexpr}
are unset, autoindent
will have no effect (* caveat 2 applies).{cindent, indentexpr, smartindent}
are unset autoindent
takes effect.(* caveat 1 ) If indentexpr
returns -1, vim specifies that the value of autoindent
is used. So, if smartindent
or cindent
is on, and autoindent
is off, and the indentexpr
evaluates to -1, indenting will not take place, which is potentially unexpected.
(* caveat 2 ) The documentation is misleading here. You should set autoindent
if you have smartindent
for reasons that are unclear (besides perhaps the reason given in (* caveat 1) above). From :h smartindent
:
Normally 'autoindent' should also be on when using 'smartindent'.
The bottom line is you should always set "lesser" indent methods when using "greater" ones, although it sometimes doesn't matter.