“Refactoring” Prose

I’ve been working on a couple of prose—as opposed to code—files. One’s fairly short (\(≈3,500\) words). The other is a bit longer (\(≈11,000\) words). I realized the other day that I was probably punctuating quotes with question marks incorrectly so I checked and found that, indeed, I’d done it wrong. In my defense, the rules for punctuating things in quotes don’t make any sense and tend toward the arcane. Regardless, the text needed fixing.

I did an occur to see how often I’d make the mistake and then I realized I could fix things on the spot by going into edit mode and using iedit to fix them all at once. The idea probably popped into my mind because of abo-abo’s great post on refactoring that did something similar.

The be clear, what I did was:

  1. Call occur with a regex describing the punctuation I wanted to correct
  2. Type e in the occur buffer to enter edit mode
  3. Mark one of the occurrences of the mistake
  4. Call iedit to fix every occurrence at once
  5. Type Ctrl+c Ctrl+c to write the changes back into the original file.

I could, of course, have used query-replace-regexp but I already had the occur buffer open and I liked being able to see all the errors at once. It’s a cute workflow for quickly making the same change multiple times in a longish file.

This entry was posted in General and tagged . Bookmark the permalink.