--- Joshua Daniel Franklin <joshuadfranklin@xxxxxxxxx> wrote:
> > --- Karsten Wade <kwade redhat com> wrote:
> > > You just need to conform to the DocBook standards. If you parse your
> > > document against the DTD, then indenting should be consistent. I'm sure
> > > there are keybindings and other DocBook tools for Vi. Perhaps someone
> > > who prefers to use Vi could make a tutorial on using Vi for DocBook with
> > > the Fedora docs project toolchain. :)
>
> > I write DocBook with Vim, so I could probaby come up with something.
>
> Sorry for the delay, this was finals week but now I'm done.
> This is a pretty basic guide, but it's enough to get started and has
> some pointers to more information. I just added a chapter after the
> emacs ones. I can work on fleshing it out with any suggestions.
Sorry, I attached the wrong xml file for the new chapter. Here is the
correct one which follows the naming convention.
__________________________________
Do you Yahoo!?
Yahoo! Mail - More reliable, more storage, less spam
http://mail.yahoo.com
<!-- $Id$ -->
<chapter id="ch-vim">
<title>VIM and DocBook</title>
<indexterm>
<primary>VIM</primary>
</indexterm>
<para>
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 <command>vimtutor</command> or by typing
<userinput>:help tutor</userinput> from inside VIM.
</para>
<sect1 id="s1-vimrc-file">
<title>Setting Up Your <filename>.vimrc</filename> File</title>
<indexterm>
<primary>VIM</primary>
<secondary>configuration file</secondary>
</indexterm>
<para>
Below is a short sample <filename>.vimrc</filename> file that turns on
some VIM features useful for editing SGML or XML content such as
DocBook:
<screen>
<computeroutput>
" 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
</computeroutput>
</screen>
</para>
<note>
<para>
Some of these features require the <filename>vim-enhanced</filename>
package to be installed. If you are using or the
<filename>vim-minimal</filename> package, or if you are using an older
version of VIM, you may not have the
<filename>$VIMRUNTIME/macros/matchit.vim</filename> file. You can still
download <ulink
url="http://vim.org/scripts/script.php?script_id=39">matchit.zip from
Vim.org</ulink> and load it separately.
</para>
</note>
</sect1>
<sect1 id="s1-vim-keymapping">
<title>Keymapping with VIM</title>
<para>
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 (<literal>\</literal>), but it can be
redefined with a command like <userinput>let mapleader =
","</userinput>. There are two ways to use the following example;
you can put it directly in your <filename>.vimrc</filename>, or you
can save it in a separate file and load it with a
<userinput>source</userinput> command in your
<filename>.vimrc</filename>.
<screen>
<programlisting>
<![CDATA[
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>> >
imap <leader>< <
]]>
</programlisting>
</screen>
</para>
<para>
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 <xref
linkend="s1-vim-additional-resources"></xref>.
</para>
</sect1>
<sect1 id="s1-vim-additional-resources">
<title>Additional VIM Resources</title>
<para>
Additional information about VIM may be found from:
</para>
<itemizedlist>
<listitem>
<para><ulink url=
"http://newbiedoc.sourceforge.net/text_editing/vim.html#JESSE-SGMLRC">
Example sgml-vimrc</ulink> from the <citetitle>Beginner's guide to
Vi Improved (VIM)</citetitle>
</para>
</listitem>
<listitem>
<para>The <ulink url="http://tnerual.eriogerg.free.fr/vim.html">VIM
Quick Reference Card</ulink>
</para>
</listitem>
<listitem>
<para>
<ulink url="http://www.pinkjuice.com/howto/vimxml/">Vim as XML
Editor</ulink>
</para>
</listitem>
<listitem>
<para>
The <citetitle>VIM REFERENCE MANUAL</citetitle>, which comes with
the <filename>vim-common</filename> package —
<filename>/usr/share/vim/<replaceable><version></replaceable>/doc/intro.txt</filename>
or type <userinput>:help intro</userinput> from within VIM
</para>
</listitem>
</itemizedlist>
</sect1>
</chapter>