我有一个令人困惑的Vim问题.如果我开始编辑一个新文件,比如使用
vim test.txt,我输入单词“do”并按Enter键(仍处于插入模式),下一行会自动缩进.在给出快速回答之前,请阅读整篇文章.
两个问题:
>为什么会发生这种情况?
>我如何调试启动过程(读取〜/ .vimrc和〜/ .vim /中的文件)?
更多信息:
>这是我的.vimrc:http://dotfiles.org/~meonkeys/.vimrc.
>“do”,“if”和“switch”都导致缩进,但我仍然没有弄清楚Vim使用缩进规则的语言.
>我在〜/ .vim /中有很多东西.这是:http://adammonsen.com/tmp/dot_vim.tgz
>我在〜/ .vimrc或〜/ .vim /中找不到任何东西,即使文件类型未设置也应该打开某种缩进!
>如果我使用vim -u / dev / null test.txt启动Vim,问题就会消失.
>是的,我知道自动设置.我不认为这是问题,因为在使用null vimrc后打开autoindent并不会在输入“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).
cinwords默认为if,else,while,do,for,switch
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。