为什么即使文件类型未设置,Vim也会使用Bash缩进规则?

Ada*_*sen 4 vim

我有一个令人困惑的Vim问题.如果我开始编辑一个新文件,比如说vim test.txt,然后输入单词"do"并按Enter键(仍然处于插入模式),下一行会自动缩进.在给出快速回答之前,请阅读整篇文章.

两个问题:

  1. 为什么会这样?
  2. 如何调试启动过程(读取〜/ .vimrc和〜/ .vim /中的文件)?

更多信息:

  • 这是我的.vimrc:http://dotfiles.org/~meonkeys/.vimrc.
  • "do","if"和"switch"都导致缩进,但我仍然没有弄清楚Vim使用缩进规则的语言.
  • 我在〜/ .vim /中有很多东西.这就是:http://adammonsen.com/tmp/dot_vim.tgz
  • 我在〜/ .vimrc或〜/ .vim /中找不到任何东西,即使filetype未设置也应该打开某种缩进!
  • 如果我开始使用Vim vim -u /dev/null test.txt,问题就会消失.
  • 是的,我知道这个autoindent设置.我不认为这是问题,因为autoindent在使用null vimrc后打开并不会在输入"do"后缩进该行.

Nei*_*eil 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).
Run Code Online (Sandbox Code Playgroud)

cinwords默认为if,else,while,do,for,switch