I have just created a file .html. When I run set filetype? I get filetype=html. Then I select this code:


and press = but the code is not indented... I don't have problems to indent php files for example using the same procedure.

  • 3
    Make sure you have set :filetype plugin indent on The indent part is important Jan 20, 2016 at 14:19
  • 2
    What's the output of :scriptnames after you open an HTML file?
    – muru
    Jan 20, 2016 at 15:47

2 Answers 2


I tried your sample (result below), so vim's html autoformat/indent definitely works with this.


Here's the steps to do it:

:filetype plugin indent on " enable the filetype indent plugin
:e                         " re-open the file (very important!)
:scriptnames               " make sure you see an ".../indent/html.vim"
:=G                        " or whatever range you want

scriptnames is the key to identifying whether the indent/html.vim is properly loaded. If not, then you probably need to re-open the file.

Note that if you put filetype plugin indent on in the ~/.vimrc, then you won't need to re-open the file since that plugin was already enabled before you opened the file.


Try checking the options mentioned in :help =:

={motion}   Filter {motion} lines through the external program
            given with the 'equalprg' option.  When the 'equalprg'
            option is empty (this is the default), use the
            internal formatting function |C-indenting| and
            |'lisp'|.  But when 'indentexpr' is not empty, it will
            be used instead |indent-expression|.  When Vim was
            compiled without internal formatting then the "indent"
            program is used as a last resort.

If it is working in php files, try comparing the values of the relevant options in each of them.

Your example works fine here, and the command :4verbose setlocal equalprg indentexpr prints the following:

    Last set from /usr/local/share/vim/vim74/indent/html.vim
  • what I get from 4verbose setlocal equalprg indentexpr is this: equalprg= indentexpr=
    – tirenweb
    Jan 20, 2016 at 14:19

Your Answer

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

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