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