I have read 'ai', 'si', 'cin', 'ci' help pages in Vim but I still cannot realize that what indention option is good for me.

Yes, I can read that :help pages again and set whatever I need in my vimrc but can I use all of the above indention options in my vimrc?

I mean, if I set them step by step, will vim conflict the options together and cause trouble in each indention?

Also I have found that setting 'si' has no effect when 'cin' is present and setting 'ci' isn't recommended when 'ai' is present. Is it true?

1 Answer 1


From :h indent.txt:

There are in fact four main methods available for indentation, each one
overrides the previous if it is enabled, or non-empty for 'indentexpr':
'autoindent'    uses the indent from the previous line.
'smartindent'   is like 'autoindent' but also recognizes some C syntax to
        increase/reduce the indent where appropriate.
'cindent'   Works more cleverly than the other two and is configurable to
        different indenting styles.
'indentexpr'    The most flexible of all: Evaluates an expression to compute
        the indent of a line.  When non-empty this method overrides
        the other ones.  See |indent-expression|.

So the 4 indent types are 'autoindent', 'smartindent', 'cindent', and 'indentexpr'.

I can ... set whatever I need in my vimrc but can I use all of the above indention options in my vimrc?

Indention settings are local to a buffer. Typically when you have filetype plugin indent on you get the default indent setting for the 'filetype'. If you want to change the indent settings for a file type I would recommend you add your changes to ~/.vim/after/indent/<filetype>.vim, e.g. ~/.vim/after/indent/c.vim.

It is also worth looking through :h indent.text as some filetypes have special options which can change indention styles/preferences.

  • Thanks. So it would be better to just turn on 'cin', yes? & How about 'ci'isn't a indention option?
    – Cy8099
    Commented Dec 5, 2017 at 17:06
  • C/C++ uses 'cindent', Python uses 'indexexpr', and Lisp uses 'autoindent'. Each filetype uses different indent settings to fit it's needs. 'copyindent' - make 'autoindent' use existing indent structure. Commented Dec 5, 2017 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.