I've got a perplexing Vim problem. If I start editing a new file, say with vim test.txt
, and I type in the word "do" and hit enter (while still in insert mode), the next line is automatically indented. Before giving a quick answer, please read this whole post.
Two questions:
More information:
filetype
is unset!vim -u /dev/null test.txt
, the problem goes away.autoindent
setting. I don't think this is the problem because turning on autoindent
after using a null vimrc doesn't indent the line after "do" is typed in.'smartindent' 'si' boolean (default off)
local to buffer
{not in Vi}
{not available when compiled without the
|+smartindent| feature}
Do smart autoindenting when starting a new line. Works for C-like
programs, but can also be used for other languages. 'cindent' does
something like this, works better in most cases, but is more strict,
see |C-indenting|. When 'cindent' is on, setting 'si' has no effect.
'indentexpr' is a more advanced alternative.
Normally 'autoindent' should also be on when using 'smartindent'.
An indent is automatically inserted:
- After a line ending in '{'.
- After a line starting with a keyword from 'cinwords'.
- Before a line starting with '}' (only with the "O" command).
cinwords defaults to if,else,while,do,for,switch
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With