Curtis Free |
Husband · Dad · Geek |
BlogReformatting reordered LaTeX paragraphs in Vim @ 07 Mar 2015While revising a non-technical paper in LaTeX recently, I found it useful to reorder the sentences in some paragraphs to improve the flow and meaning of the text. In doing this, I often manually deconstructed the text into separate sentences in the source to make reordering easy. As an extreme example, I would go from this:
To this (sentences in question starting on newlines):
Then to this (some sentences reordered):
With the sentences reordered, I needed to reformat the source to restore the clean style seen in the
first example. Those familar with Vim likely think of
While that looks nice at quick glance, further inspection reveals that there are two spaces between certain sentences. Some additional Vim commands can clean that up, but it's even easier if one introduces a command to accomplish the task. I added the following to my Vim configuration:
Now,
(That last item is important because I don't want Vim to highlight all occurrences of multiple spaces should I have space indents and the like elsewhere in my source.) Using
| |
[ CC BY-SA 4.0 ] |