Schema-aware XML editing in Vim Schema-aware XML editing in Vim xml xml

Schema-aware XML editing in Vim


VIM 7+ supports that by default without any plugins, it can load XML definition, there are converters for DTD and SchemaNG:

http://vimdoc.sourceforge.net/htmldoc/insert.html#ft-xml-omni

For example my Vim 7.3 already have definitions for XHTML:

$ rpm -ql vim vim-common | grep xml/usr/share/vim/vim73/autoload/xml/usr/share/vim/vim73/autoload/xml/html32.vim/usr/share/vim/vim73/autoload/xml/html401f.vim/usr/share/vim/vim73/autoload/xml/html401s.vim/usr/share/vim/vim73/autoload/xml/html401t.vim/usr/share/vim/vim73/autoload/xml/html40f.vim/usr/share/vim/vim73/autoload/xml/html40s.vim/usr/share/vim/vim73/autoload/xml/html40t.vim/usr/share/vim/vim73/autoload/xml/xhtml10f.vim/usr/share/vim/vim73/autoload/xml/xhtml10s.vim/usr/share/vim/vim73/autoload/xml/xhtml10t.vim/usr/share/vim/vim73/autoload/xml/xhtml11.vim/usr/share/vim/vim73/autoload/xml/xsd.vim/usr/share/vim/vim73/autoload/xml/xsl.vim/usr/share/vim/vim73/autoload/xmlcomplete.vim/usr/share/vim/vim73/compiler/xmllint.vim/usr/share/vim/vim73/compiler/xmlwf.vim/usr/share/vim/vim73/ftplugin/xml.vim/usr/share/vim/vim73/indent/xml.vim/usr/share/vim/vim73/syntax/docbkxml.vim/usr/share/vim/vim73/syntax/xml.vim

Try it, it's worth it. Everything is documented clearly under the link above, I will not copy-paste it here.


The closest thing that I've seen for Vim is the XML Completion script.

It contains XML definition files for DocBook 4.[234], XSL FO 1.0, XSLT 1.0, Relax NG 1.0, XML Schemas 1.0, SVG 1.1, XHTML 1.1, XInclude 1.0 and OpenOffice 1.0 XML format.


Reference: http://ricardianambivalence.com/2013/02/17/xml-validation-in-vim/

With the bar.xml open, you can easily validate against foo.xsd. First, save your changes and then hit : and enter the following (it's the pipe to the terminal command).

:! xmllint --noout --schema foo.xsd bar.xml