简体   繁体   中英

VIM html autoindent not working

I try to get autoindent to work in VIM with html files, but unfortunately it won't work. Autoindent works perfectly with other languages, but it just won't work with html. I've already tried setting the filetype to html , as suggested in this question, but unfortunately it doesn't work either. Also, when I select everything and press = it doesn't indent as well, even though vim reports XX lines indented .

My .vimrc file looks like this:

set autoindent 
set cindent 
set tabstop=4 
set shiftwidth=2 
set expandtab

Any suggestions?

You have to add the following lines to your .vimrc to make sure vim uses file-specific indentions:

filetype on
filetype plugin on
filetype indent on

This way it will indent html as html when the filetype is set to html .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM