Vim Tips Wiki
Register
Advertisement

Previous TipNext Tip

Tip: #517 - Rejustify roff style markup

Created: July 23, 2003 18:28 Complexity: intermediate Author: Cameron Kerr Version: 5.7 Karma: 5/2 Imported from: Tip#517

Normally, I bind F4 to gqap, which suffices nicely to rejustify plain text, and most of my latex and HTML stuff (with due care taken to have plenty of blank lines for delimiting.


However, if you're dealing with *roff style markup, such as man-pages or (in my case) documents using the -ms groff macros, it won't work, as the tags

are on the line just above, such as the following example.


<begin example>

.IP Boggart

Magical being that transforms into whatever the viewer most fairs.

Proffessor Lupin used a boggart to

teach Harry how to repel Dementors, as

(at that time) Harry most faired Dementors.


<end example>


Ideally, I'd just position the cursor on the body of the text (this a definition list entry, if anyone is wondering), and just press F4. But that would also rejustify the argument to the IP macro, which would be bad.


So instead of using gqap, I use gq an a selected range of lines. I search upwards something that might be a macro, or a blank line, move down a

line into the body, start to select, search forward for the next macro or

blank line, then gq to rejustify.


The regex I use to search for the extents is

\(^\.[A-Za-z]\{2\}\\

Comments

Advertisement