I read the wiki entry on vim source code indentation
I still can't understand the difference between autoindent
and smartindent
It seems they do the same thing, copy the indentation level to next line when you press enter
.
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 communityI read the wiki entry on vim source code indentation
I still can't understand the difference between autoindent
and smartindent
It seems they do the same thing, copy the indentation level to next line when you press enter
.
autoindent
essentially tells vim to apply the indentation of the current line to the next (created by pressing enter in insert mode or with O or o in normal mode.
smartindent
reacts to the syntax/style of the code you are editing (especially for C). When having it on you also should have autoindent
on.
:help autoindent
also mentions two alternative settings: cindent
and indentexpr
, both of which make vim ignore the value of smartindent
.
set
command in the beginning. i.e. set autoindent
:help autoindent
and:help smartindent
.