Vim as XML Editor: About

... this howto.


The HTML pages should be pretty accessible, as listed on

The pages can be navigated via keys:

Access Keys


next page


previous page


index page

For example in NN6+/Mozilla, use [alt-n] to go to the next page, and [alt-p] to come back. In other browsers such as IE6, the access keys just give focus to the associated link, so the sequence becomes [alt-n] [enter].


Most importantly, you should be familiar with Vim. If that's not the case, check out the next section and come back in a few days.

Learning Vim

Teaching Vim is outside of the scope of this howto. Here are some resources, ranging from basic to advanced:
  • First you should make sure that you have the latest version of Vim. Vim is available for many OSs, check I recommend to use GVim, the GUI version of Vim, unless you're in a remote shell session.
  • Vim comes with a tutorial. After firing up Vim, enter :help tutor. One way to start with it is to read it into the buffer
    :read $VIMRUNTIME/tutor/tutor
    optionally delete the first line via g g d d, then write it to some file
    :write del/vim_tutorial.txt
  • Vim comes with lots of documentation which you can consult while working with Vim. Simply enter :help.
  • More documentation including the FAQ is listed on
  • There's a book about Vim titled "Vi IMproved - Vim" (New Riders Publishing, Author: Steve Oualline, ISBN: 0735710015). You can buy it through the book page on A list of errata is listed on the publisher's page (search for "vim") and the creator of Vim Bram Moolenaar also maintains a list of errata.


All instructions are just examples, TMTOWTDI. For example: To move the cursor upwards I use [up], others use k.


Key sequences to be entered in Vim are written like this: 2 G [ctrl-v] [down] x. All commands are to be entered in normal mode. Insert mode commands start with an i, command line ones start with a :. Longer commands that are to be entered in Vim's command line are written like this:

In key sequences like this one [mapleader] x i < c h a p t e r > > [up] each group of non-space characters stands for one key press. If a space is to be entered it is listed as [space].

Vim commands and option names most often have a full and an abbreviated version. When using Vim I use the short versions, eg :h for :help, :w for :write, :q for :quit, etc. In the howto I sometimes use the full versions because they explain themselves better.

Mappings in Vi can be specified to start with <Leader>, which is a variable that can be set in the vimrc; see :help mapleader. If you did set your mapleader to some character other than the default (\), use this character instead wherever [mapleader] is written.

I don't use the notation used in Vim scripts because I think it's not very descriptive. If you want to use some of the commands in your Vim scripts, you must translate the function keys, eg [enter] to <CR> and [backspace] to <BS>.

Code that's to be entered in the shell of the OS most often is listed like this:
$ cd foo
The prompt character $ may indicate that the command is Linux-specific, and a > before a command may mean that the command is Windows-specific (to be entered in the "MS-DOS Prompt"). If there is no prompt character the command should work on at least both OSs.


"Linux" most often stands for Unix-like systems such as GNU/Linux, BSD, etc.

Installation on Linux


The Vim download page contains instructions and offers various formats.

If your distro came with sample files containing Vim settings you might want to disable them, eg by appending .bak to their name or by moving them to some backup directory. :version lists these files.

If you want additional features you might have to compile Vim yourself, check the README and INSTALL files. Here's a shortened version of how I installed it (after having resolved some dependencies such as termcap, ncurses-devel, XFree86-devel, pkgconfig).
$ wget -q \
$ tar -xjf vim-6.3.tar.bz2
$ cd vim63/
$ ./configure \
> --prefix=$HOME/bulk/run/vim/6_3 \
> --with-features=big \
> --enable-gui=gtk2 \
> --with-compiledby='tobiasreif pinkjuice com' \
> --enable-rubyinterp \
> 2>&1 | tee > config.log
$ make 2>&1 | tee > make.log
$ make test 2>&1 | tee > test.log
$ make install 2>&1 | tee > install.log
$ ed
#!/usr/bin/env sh
${HOME}/bulk/run/vim/6_3/bin/vim "$@"
w /home/tobi/data/commands/vim
$ ed
#!/usr/bin/env sh
${HOME}/bulk/run/vim/6_3/bin/gvim "$@"
w /home/tobi/data/commands/gvim
$ chmod 700 ~/data/commands/vim
$ chmod 700 ~/data/commands/gvim
$ vim --version | head -n 3
VIM - Vi IMproved 6.3 (2004 June 7, compiled Jun 10 2004 15:19:15)
Compiled by tobiasreif pinkjuice com
Big version with GTK2 GUI.  Features included (+) or not (-):
$ ed ~/.bashrc
export EDITOR='/usr/bin/vim'
export EDITOR='/home/tobi/data/commands/vim'
$ rpm -v --test --erase gvim
$ rpm -v --test --erase kvim
$ su root
# rpm -v --erase gvim
# rpm -v --erase kvim
# rpm -v --test --erase vim
# rpm -v --erase vim
# SuSEconfig
# exit
$ ed ~/.bashrc
export MANPATH

$ source ~/.bashrc
$ man vim
Reformatting vim(1), please wait...
Then I made vim available to root:
$ su -
# vim
-bash: vim: command not found
# ed .bashrc

alias vim='/home/tobi/bulk/run/vim/6_3/bin/vim'

# vim
-bash: vim: command not found
# source .bashrc
# vim
# exit


There are many different ways to install software on Linux. For some tools I describe how I installed them, but those are just examples; you'll most likely have different preferences and a different environment. I guess one typical strategy would be:
  1. Ask your package manager, try it on the command line: Is the tool already installed? Is it up to date?

  2. Otherwise check if there's a sufficiently recent package (eg .deb or .rpm) supplied by your distro project or vendor...

  3. ... or by the project itself ...

  4. ... or by a third party, if you trust it. In this and the former case it makes sense to check if there's a package specifically for your distro and -version.

  5. Otherwise you could get the source from the project web site then compile and install via some variation of the common ./configure;make;make install command sequence . If you don't want to risk conflicts caused by systemwide installation you can install the tool as user somewhere under your home directory, by omitting make install or by overriding the default installation directory.

  6. Or the project might provide a binary for your platform.


Here are the DBX sources and the pics.



This howto deals with XML editing thus does not deal with setting up a DocBook publishing environment. DBX documents and schemas are used as examples representing XML languages in general. Explaining how to get (X)HTML or PDF from DBX is outside the scope of this howto. Getting started is simple, but typically there's a lot more to it. For example if you use the XSLTs check out Bob Stayton's DocBook XSL: The Complete Guide.


The online version is generated by a set of XSLTs I have written (they are not a customization layer for an existing package). The files are listed for the curious; they are not published as supported releases. You're free to use the XSLTs, but you're on your own :). I wrote them to get the kind of XHTML I like. Ideally it should be
purely structural

no presentational markup

used appropriately

regarding semantics and structure (no tables except for tabular data, etc)

valid XHTML 1.0 Strict

not so difficult, since I only use a subset of DocBook


implementing many but not all WAI guidelines (WCAG 1.0)

Please drop me a line if you experience any problems.
Here are the XSLT files used to generate the online version of this howto. They work well for me, but they are
  • very incomplete,
  • not general or flexible enough,
  • and quirky to set up and run,
so I don't recommend to use them.

The XSLTs are under the GPL. A rewrite of the DocBook to XHTML XSLT set will be at


If you're looking for XSLTs that you can use to transform any DocBook document to various formats, you might want to check out the XSLTs. They are very complete and have various customization hooks. The project provides packaged releases, and most importantly, it provides support.

Joocs might become an alternative to existing packages in the future, but it will be a while before Joocs supports all of DBX. It only supports XHTML output and will only be interesting for a subset of scenarios.


I use the XSLTs to get XSLFO from DBX. Here is the customization layer and here are the XSLFO and PDF files. FOP was used to get PDF from the XSLFO.