I am thinking on a similar solution, which Eclipse also does: during the editing, the editor tries to always hold in a "well-indented" format of the edited textual data.

Ideally, it would happen very strong: the best were if anything breaking the well-formatting would be corrected on the spot.

Is it somehow possible?

1 Answer 1


I commented out my entire .vimrc file, then added a few indentation related things. Using the process of elimination, I landed on the following line being solely responsible getting my XML indentation to work:

filetype plugin indent on

However, this only worked when loaded from the .vimrc file. Manually typing it in had no effect for me.

According to :h filetype-indent-on:

You can enable loading the indent file for specific file types with: :filetype indent on

If filetype detection was not switched on yet, it will be as well. This actually loads the file "indent.vim" in 'runtimepath'. The result is that when a file is edited its indent file is loaded (if there is one for the detected filetype). |indent-expression|

If you have filetype indent on enabled in your .vimrc and don't have indentation, you're probably missing the indentation definition file.

  • Additionally, you may or may not need to set nocompatible in your .vimrc file. It's generally good practice to set it unless you absolutely need vi compatibility.
    – Cody Poll
    Feb 11, 2015 at 11:08

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.