Vim as XML Editor: Intro

Vim is a great editor with many features, and it's extensible. So by learning a subset of the features, customizing it by setting preferences, and by extending it with plugins and scripts, each user builds his own editor. Existing extensions are available from www.vim.org/ (alternative URL: vim.sourceforge.net/).

Vim also is very fast and is available for many platforms. I use Vim for all my editing (
  • XHTML,
  • Ruby,
  • XSLT,
  • CSS,
  • DBX,
  • SVG,
  • etc.
) which means that I don't have to learn a new editor for each language. On my Vim page there's some general info.

Vim is a text editor, and even when extended with some XML specific functionality, it is not a full-blown XML editor: For example, there's no tags- or WYSIWYG view, and no real structure/tree view. I don't really miss entry help (context-sensitive suggestions for completion), but this and other schema-driven (DTD, WXS, RNG, etc) functionality found in editors like nXML could be implemented using Vim's Python interface plus libxml's Python bindings, for example.

But since XML editing most often also involves a lot of general text editing tasks, and Vim offers such a vast range of functionality for those, Vim can be set up to be a surprisingly useful XML editor, especially for people who like reading the documentation and schemas of the specific XML language.

This is not really a howto. It's more a collection of tips, examples, and ideas than a complete instructional guide intended to be read from cover to back. I will simply show my current setup; there are many different variations possible. You could for example browse the sections, then pick the things which seem useful to you. There's a Vim XML Wiki page on the SVG Wiki, and on vim.org you can search for XML scripts and XML tips. Please add your tips, scripts, and links.

Vim is Free Software and Charityware. If you like and use it, please consider making a donation to ICCF Holland. Also see :help uganda.

Most of the things described should work on Linux and other Unix-like operating systems such as BSD, and might also work on Windows. If you're using an emulation layer things might complicate. For example if you're using Cygwin you'll probably have to figure out some mix of the Linux and Windows setup instructions.

Note

Some of the Windows-specific stuff might be outdated since I don't have Windows anymore.

Many of the tools and techniques described in this howto can also be used without Vim, for example from the shell, from scripts, and from other editors.

Remote Session

Vim screenshot: PuTTY window.

There are some more screenshots at www.pinkjuice.com/howto/vimxml/pics/screens/.