Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Schema-aware XML editing in Vim

Tags:

When editing an XML file in IntelliJ IDEA, if the document references a schema, IDEA will fetch the schema and use the information for auto-complete. It knows which tags are valid in which contexts, so when you hit CTRL-space, it suggests only those tags. It also highlights any tags that are invalid according to the schema.

Does anybody know of an extension for Vim that provides similar functionality?

like image 803
Dan Dyer Avatar asked Nov 26 '08 23:11

Dan Dyer


2 Answers

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.

like image 119
lzap Avatar answered Oct 06 '22 10:10

lzap


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.

like image 40
Christian C. Salvadó Avatar answered Oct 06 '22 08:10

Christian C. Salvadó