I was using vim on Debian 7 to edit an HTML document. I started typing: <HTML>
Return…
After the initial return, the cursor was indented one level, so that as I typed <head>
, and the rest of my document, it would show up like this:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Test page</title>
</head>
<body>
<div>
<p>This is a paragraph.</p>
</div>
</body>
</html>
The tag on each line was simply followed by a Return and no presses on the Tab or Space key, and vim formatted this as I expected. Also, when typing the initial </
of a closing tag, vim would unindent that line so as to match the level of the corresponding opening tag.
Then, typing the same document into vim on Ubuntu 13.10, as I'm typing the very same document in the same manner, I get the following results:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Test page</title>
</head>
<body>
<div>
<p>This is a paragraph.</p>
</div>
</body>
</html>
Notice that the indentation doesn't start until the <p>
tag, and I suppose any of its subsequent sibling and child elements. It seems that later versions of the HTML indentation style have opted to not indent tags such as html, head, body, etc.(?), for legibility.
I don't like the fact that vim doesn't indent all tags. What can I do to change this?
I tried looking at the indentation files for the different versions, but I didn't manage to figure out if I could do anything there. pastebins:
- /usr/share/vim/vim73/indent/html.vim on Debian 7
- /usr/share/vim/vim74/indent/html.vim on Ubuntu 13.10
I'm using the following versions of vim:
- Debian 7: "Vi IMproved 7.3 (2010 Aug 15, compiled Feb 10 2013 02:27:59)"
- Ubuntu 13.10: "Vi IMproved 7.4 (2013 Aug 10, compiled Aug 12 2013 00:28:05)"
vim
package is installed, i.e. I don't have thevim-tiny
package that is installed by default on Ubuntu. I also havefiletype plugin indent on
in my.vimrc
.