我有一个令人困惑的Vim问题。如果我开始编辑一个新文件,比如说vim test.txt
,我输入单词“do”并按Enter键(仍然处于插入模式),下一行会自动缩进。在给出快速回答之前,请阅读整篇文章。
两个问题:
更多信息:
filetype
未设置也应该打开某种缩进!vim -u /dev/null test.txt
启动Vim,则问题就会消失。autoindent
设置。我不认为这是问题所在,因为在使用null vimrc后打开autoindent
并不会在输入“do”后缩进该行。答案 0 :(得分:8)
'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默认为if,else,while,do,for,switch