Adam Monsen
Adam Monsen

Reputation: 9420

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

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:

Upvotes: 4

Views: 1129

Answers (1)

Neil
Neil

Reputation: 55402

'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

Upvotes: 8

Related Questions