Vim Macros for Editing DocBook Documents
The macros are bound to function keys (F-Keys) followed by zero, one or two modifier characters. Function keys are specified as <FN>, where N is the function key number. Shifted function keys are specified as <S-FN>. The key mappings are detailed belwo in Tables 1-4.
Table 1. Key Mappings
| Key Sequence | Mapping |
|---|---|
| <F2>tag-keys | Insert tag template. Inserts a template for the tag corresponding to the specified tag-keys in the document. See Table 2 for a list of defined tag-keys. |
| <F3>symbol-keys | Insert symbol character. Inserts the symbol character corresponding to the specified symbol-keys in the document. Most often, this inserts the DocBook/XML entity reference for the symbol. See Table 3 for a list of defined symbol-keys. |
| <F4>foreign-char-keys | Insert foreign character. Inserts the foreign character corresponding to the specified foreign-char-keys into the document. See Table 4 for a list of defined foreign-char-keys. |
| <F5>tag-keys | Insert opening tag. Inserts the opening tag corresponding to the specified tag-keys. |
| <F6>tag-keys | Insert closing tag. Inserts the closing tag corresponding to the specified tag-keys. |
| <F7>tag-keys | Tag word. If the cursor is on a word, this places tags corresponding to the specified tag-keys around the word. |
| <F7>tag-keys | Tag range (command mode). When a range of lines is specified, this places tags corresponding to the specified tag-keys around the lines. Note: this is done in command mode; type a colon followed by the key sequence. |
| <F8>tag-keys | Change tag. If the cursor is on a tag, this changes the tag to the tag that corresponds to the specified tag-keys. |
| <F9> | Move cursor to the left by tags. If the cursor is on a tag, this moves to the beginning of the tag (to the <). If the cursor is not on a tag, this moves to the beginning of the next tag to the left of the cursor. |
| <F10> | Move tag left of preceding word. If the cursor is on a tag, this moves the tag to the left of the preceding word. In other words, if the cursor is on a start tag, it expands the amount of tagged content to include the word to the left of the tag. If the cursor is on an end tag, it removes the word to the left of the tag from the tagged contents. |
| <F11> | Move tag right of following word. If the cursor is on a tag, this moves the tag to the right of the following word. In other words, if the cursor is on a start tag, it removes the word to the right of the tag from the tagged contents. If the cursor is on an end tag it, expands the amount of tagged content to include the word to the right of the tag. |
| <F12> | Move cursor to the right by tags. If the cursor is on a tag, this moves to the end of the tag (to the >). If the cursor is not on a tag, this moves to end of the next tag to the right of the cursor. |
| <S-F8> | Delete tag. If the cursor is on a tag, this deletes the tag. |
| <S-F9> | Delete whitespace to the left of the tag. If the cursor is on a tag, this deletes any whitespace to the left of the tag. |
| <S-F10> | Insert a space to the left of the tag. If the cursor is on a tag, this inserts a single space to the left of the tag. |
| <S-F11> | Insert a space to the right of the tag. If the cursor is on a tag, this inserts a single space to the right of the tag. |
| <S-F12> | Delete whitespace to the right of the tag. If the cursor is on a tag, this deletes any whitespace to the right of the tag. |
The following keys are used in combination with the function keys <F2>, <F5>, <F6>, <F7> and <F8> . The function key determines the action; the keys that follow determine the tag.
Table 2. Tag Keys
| Keys | Corresponding Tag |
|---|---|
| a | <article> |
| b | <emphasis role="bold"> |
| c | <command> |
| d | <entry> |
| e | <email> |
| f | <function> |
| h | <title> |
| i | <emphasis> |
| jd | <remark role="web-pub-date"> |
| ji | <remark role="author-image"> |
| jl | <remark role="layout-info"> |
| jn | <remark role="article-number"> |
| jo | <remark role="output-file"> |
| jp | <remark role="pull-quote"> |
| js | <remark role="article-section"> |
| jt | <remark role="teaser"> |
| jw | <remark role="article-series"> |
| k | <command role="what-to-type"> |
| l | <listitem> |
| m | <mediaobject> |
| n | <itemizedlist> |
| o | <orderedlist> |
| p | <para> |
| q | <quote> |
| r | <row> |
| s | <sidebar> |
| t | <table> |
| u | <ulink> |
| xa | <author> |
| xb | <blockquote> |
| xc | <
It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Featured Jobs
| Linux Systems Administrator | Houston and Austin, Texas | Host Gator |
| Senior Perl Developer | Austin, Texas | Host Gator |
| Technical Support Rep | Houston and Austin, Texas | Host Gator |
| UX Designer | Austin, Texas | Host Gator |
| Web & UI Developer (JavaScript & j Query) | Austin, Texas | Host Gator |
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?



Comments
Re: Vim Macros for Editing DocBook Documents
i copied the 4 macro files in the article, but i get the following errors when doing, ":so maps.vim"...
i xb
it sort of just gets worse from there...
Re: Vim Macros for Editing DocBook Documents
It works now when downoading the files from the LJ server.
But there is a bug that inserts closing tags...
For example:
<F2><n> produces:
<itemizedlist>
<listitem><para></para></listitem>
</itemizedlist></para></listitem></itemizedlist>
<F2><p> produces:
<para>
</para></para>
If this could be fixed it would really make editing a lot easier so plz look over the code and post an update :-)
Morten Damsgaard-Madsen
Denmark
Where is the linuxjournal ser
Where is the linuxjournal server that you downloaded the files from?
ftp://www.linuxjournal.com/pu
ftp://ftp.ssc.com/pub/lj/listings/Web/7737.tar.gz
Re: Vim Macros for Editing DocBook Documents
As usual the socurce of errors is right in front of the computer ;-).
The script works as expected - I just forgot that I had the xml.vim script installed which interacts with these macros in funny ways...
Nice work!
/Morten
Re: Vim Macros for Editing DocBook Documents
I use Vim 6.2 and I get the same error.
If you observe the error shown, it says that a variable is undefined.
If you look into mfuncs.vim, you will see that "etags" is defined
in a conditional statement and used anyway subsequently.
Therefore, in the cases where the conditional statement is missed,
"etags" is undefined subsequently.
The author should have a look at the code one again and post here an update.
Re: Vim Macros for Editing DocBook Documents
Same goes for me: the version of vim I use is 6.3. Maybe the macros of this article are meant for an older version ?