Vim Macros for Editing DocBook Documents

Macros for key mappings, tags and entities that can be used with DocBook/XML and other similar markup languages.
Conculsion

If you're a vim user and you need to edit DocBook, the macros described here can make your job easier by providing you with vim key bindings for inserting tags and entities, as well as for inserting predefined tag templates. It also provides key bindings that allow you to move tags in your document and to move through your document by way of tags.

Although originally designed for use with DocBook/XML, these macros could be used with any similar markup language, such as HTML, SGML or other XML-based markup languages.

______________________

Mitch Frazier is an Associate Editor for Linux Journal.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Re: Vim Macros for Editing DocBook Documents

Anonymous's picture

i copied the 4 macro files in the article, but i get the following errors when doing, ":so maps.vim"...

i xb

i xc [CDATA[-:-]]?-:-3xi
Error detected while processing function MapTagKey:
line 57:
E121: Undefined variable: etag
E15: Invalid expression: "imap " . s:InsertEndTagKey . a:key . eicmd . etag
line 58:
E121: Undefined variable: etag
E15: Invalid expression: "nmap " . s:InsertEndTagKey . a:key . encmd . etag
line 61:
E121: Undefined variable: etag
E116: Invalid arguments for function escape(etag, """)
E15: Invalid expression: escape(etag, """)

it sort of just gets worse from there...

Re: Vim Macros for Editing DocBook Documents

Anonymous's picture

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

Anonymous's picture

Where is the linuxjournal server that you downloaded the files from?

ftp://www.linuxjournal.com/pu

Pablo's picture

Re: Vim Macros for Editing DocBook Documents

Anonymous's picture

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

Anonymous's picture

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

Anonymous's picture

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 ?

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState