Chapter 5. VIM and DocBook

5.1. Setting Up Your .vimrc File
5.2. Keymapping with VIM
5.3. Additional VIM Resources

VIM has many features to help you write XML content such as DocBook, including syntax highlighting and customizable key bindings. Additionally, one can easily use external programs from VIM for features such as spell-checking. This chapter assumes you already know generally how to use VIM; if you want to learn how, try the vimtutor or by typing :help tutor from inside VIM.

5.1. Setting Up Your .vimrc File

Below is a short sample .vimrc file that turns on some VIM features useful for editing SGML or XML content such as DocBook:


" Turn off vi compatibility settings like limited undo
set nocompatible
" Syntax highlighting based on file extension
syntax on
" Automatically insert newlines after 80 characters
set textwidth=80
" Automatically indent
set autoindent
" Match SGML tags with %
source $VIMRUNTIME/macros/matchit.vim

[Note]Note

Some of these features require the vim-enhanced package to be installed. If you are using or the vim-minimal package, or if you are using an older version of VIM, you may not have the $VIMRUNTIME/macros/matchit.vim file. You can still download matchit.zip from Vim.org and load it separately.