5.2. Keymapping with VIM

VIM can speed up your DocBook creation by mapping frequently typed tags (or any words or phrases) onto short key combinations. By default, the keymap leader is the backslash (\), but it can be redefined with a command like let mapleader = ",". There are two ways to use the following example; you can put it directly in your .vimrc, or you can save it in a separate file and load it with a source command in your .vimrc.

      
      
let mapleader = ","

" skip ahead to after next tag without leaving insert mode
imap <leader>e <esc>/><cr>:nohlsearch<cr>a

" common tags that start a new text block
imap<leader>pa <para><cr></para><esc>O
imap<leader>s1 <sect1 id=""><cr><para><esc>jo</sect1><esc>O
imap<leader>pl <programlisting><cr></programlisting><esc>O<esc>0i
imap<leader>cp <computeroutput></computeroutput><esc>O<esc>0i

" common tags that are placed inline
" use <esc>F>a
imap<leader>en <envar></envar><esc>F>a
imap<leader>fi <filename></filename><esc>F>a
imap<leader>lt <literal></literal><esc>F>a
imap<leader>re <replaceable></replaceable><esc>F>a
imap<leader>ui <userinput></userinput><esc>F>a
imap<leader>ul <ulink url=""></ulink><esc>F>a
imap<leader>si <systemitem></systemitem><esc>F>a
imap<leader>us <systemitem class="username"></systemitem><esc>F>a
imap<leader>sy <systemitem class="systemname"></systemitem><esc>F>a
imap<leader>cm <command></command><esc>F>a                                  
" entities
imap <leader>> &gt;
imap <leader>< &lt;

      

Unfortunately, there is not currently a complete macro set for all DocBook commands, so you will need to define them yourself or customize the definitions in the examples from Section 5.3, “Additional VIM Resources”.