sponsor Vim development Vim logo Vim Book Ad

HTML AutoCloseTag : Automatically closes HTML tags once you finish typing them.

 script karma  Rating 212/89, Downloaded by 6723  Comments, bugs, improvements  Vim wiki

created by
Michael Sanders
 
script type
ftplugin
 
description
Automatically closes HTML tag once you finish typing it with >. It is also smart enough to not autoclose tags when in a comment, when they are self-closing, or when they have already been closed.

So, <body id="foo">, upon typing >, will become <body id="foo">|</body>, where | is the cursor.
But, if you type <img src="bar.png">, the script knows to keep it the same.
 
install details
Move html_autoclosetag.vim to ~/.vim/ftplugin (or equivalent, e.g. $HOME\vimfiles\ftplugin on Windows)

To enable for xhtml/xml files, remember to add this to your .vimrc:
au FileType xhtml,xml so ~/.vim/ftplugin/html_autoclosetag.vim (or wherever you put it)
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
html_autoclosetag.vim 0.3 2009-05-16 7.0 Michael Sanders Fixed bug with closing tag when on the start of the line, and cleaned up the code a bit.
html_autoclosetag.vim 0.2 2009-03-27 7.0 Michael Sanders Initial upload
ip used for rating: 3.237.186.170

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github