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.

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.

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.

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.

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 pinkjuice.com/howto/vimxml/pics/screens/.