开发者

why does Vim use Bash indenting rules even when filetype is unset?

开发者 https://www.devze.com 2023-03-14 17:40 出处:网络
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 inden

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:

  1. Why might this happen?
  2. How can I debug the startup process (reading ~/.vimrc and files in ~/.vim/)?

More information:

  • Here's my .vimrc: http://dotfiles.org/~meonkeys/.vimrc.
  • "do", "if", and "switch" all cause indenting, but I still haven't figured out what language Vim is using indent rules for.
  • I do have a bunch of stuff in ~/.vim/. Here's that: http://adammonsen.com/tmp/dot_vim.tgz
  • I can't find anything in my ~/.vimrc or ~/.vim/ that should turn on some kind of indenting even if filetype is unset!
  • If I start Vim using vim -u /dev/null test.txt, the problem goes away.
  • Yes, I know about the autoindent setting. I don't think this is the problem because turning on autoin开发者_如何学Godent 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

0

精彩评论

暂无评论...
验证码 换一张
取 消