guilin 桂林
guilin 桂林

Reputation: 17422

xml.vim does not close tag for html automatically

When editing xml, xml.vim works great for tag close. But when editing html, it does not work. Vim version is 7.3

Upvotes: 0

Views: 590

Answers (2)

sth
sth

Reputation: 229603

I'm not sure what exactly you are asking, but the reason is probably that classical HTML is much less strict with which tags have to be closed. In HTML it's common to have tags that are not explicitly closed, like for example <p>. My guess would be that therefore vim isn't as eager to close tags when editing HTML.

If you write XHTML and always want all tags closed, maybe setting the file mode to XML with setf xml will help. If you don't write XHTML it might be that xml.vim gets confused by all the unclosed tags and therefore doesn't work correctly.

Upvotes: 0

ZyX
ZyX

Reputation: 53624

I do not know, where you have found xml.vim, but it is probably due to filetype: xml filetype is xml and html one is html, so xml.vim is not loading. You can do the following:

  1. Change filetype to xml for html files.
  2. Add a symlink to xml.vim to ~/.vim/ftplugin/html/.
  3. Add a sourcing of xml.vim for html files to your vimrc:

    augroup vimrcHTMLsoXML
        autocmd Filetype html runtime! ftplugin/xml.vim
    augroup END
    

Upvotes: 1

Related Questions