I'm trying to get Vim (version 7.4), running on Ubuntu (14.04 LTS), to apply automatic indentation to HTML files. I know from the answers to this question that several tags you'd expect to cause indentation are not indented by default in Vim 7.4, and I know that's not the problem. Even the <div>
tag, which should cause indentation in the default configuration, does not result in any indentation for me. If I type in the minimal example from this question, I get the following:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Test page</title>
</head>
<body>
<div>
<p>This is a paragraph.</p>
</div>
</body>
</html>
Note that the <p>
is not indented inside the <div>
. Even if I save the file and do gg=G
, Vim displays 12 lines indented
but the <p>
remains unindented.
My .vimrc has the required lines
set autoindent
filetype indent plugin on
set shiftwidth=4
set tabstop=4
If I do :set filetype?
while editing the example HTML file, I get filetype=html
so the filetype is getting detected properly, and /usr/share/vim/vim74/indent/html.vim
exists. Furthermore, syntax highlighting is correct for HTML, so at least some filetype-specific files are getting loaded correctly.
Does anyone know why the indenting rules aren't being applied to HTML files?
` inside the `