Reputation: 2568
Is it possible to get Vim to auto indent closing tags in HTML? Here is an illustration of the issue I am having:
You can see that it indents the opening tags perfectly but when I have a closing tag, they don't indent in line with the opening one. To be clear here is how I would want that example to indent:
<div class="first">
<div class="second">
thing
</div>
</div>
Is there a simple way to fix this?
I know about running gg=G to indent the file at the end but I'm specifically looking to get the indenting happening as I type.
As an aside, in Sublime Text 3 I get around the issue using Emmet – each time you expand it places the cursor in the correct position. However, the Vim version behaves oddly, failing to auto indent so that's not a possible solution either.
In case relevant, here is a link to my current .vimrc: https://gist.github.com/benfrain/f09dd39e66fe2da9cf0a
Upvotes: 1
Views: 1516
Reputation: 196596
The behavior you ask for has been the default behavior for quite a while. The default Vim on Mac OS X (7.3.000, released in 2010) does that and the latest MacVim (7.4.258) does that too.
Could you post your ~/.vimrc
, please?
edit
I tested your vimrc
, with all the vundle stuff, all the mappings to non-existing commands, and generally stuff that couldn't work here (backupdir, colorscheme…) commented out and I get the normal and expected behavior.
I would suggest you bisect your vundle plugins.
FWIW, there are a few mistakes in your vimrc
but they don't seem to have any impact on your current problem:
Upvotes: 3
Reputation: 5186
I would suggest installing one of the alternative HTML indentation plugins, which will also address other quirks in addition to closing tags:
http://www.vim.org/scripts/script.php?script_id=2075
http://www.vim.org/scripts/script.php?script_id=1830
Upvotes: 0