tags:

views:

46

answers:

2

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

+1  A: 

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
    
ZyX
Exactly, it supports html, but vim is matching the plugins based on filename so you need to symlink html.vim -> xml.vim.
Rick
A: 

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.

sth
I'm thinking you're right about the question here. Just a comment that the xml.vim plugin has a setting to treat HTML files as XHTML: let xml_use_xhtml = 1 (see :help xml-plugin for more info).
dsummersl