I recently discovered an awesome capability of Emacs, where I can use occur to pull all matching lines into a split window and press e to enter occur-edit-mode. In this mode I can do things like replace-string to modify all of the matching lines in my original buffer.

This only modifies the occurrences, and is fantastic! The best part is that I can see all of the potential changes to the original buffer in a concise, noise-free area.

Shortcoming

This mode does not currently have evil bindings. I can test my regex by using evil-ex - I get my lovely red strike-through and expected changes, but entering evil-ex seems to disable the edit capabilities of the occur-edit-mode and I'm left with a read-only buffer.

Current Workflow

I'm modifying 20+ large files with many rewrite rules and have come up with the following:

  1. Use eshell to create a grep buffer across all relevant files.
  2. Test my regex using : (evil-ex) in the grep buffer
  3. Verify that all buffers will change as desired.
  4. Jump to each matching file from the grep buffer one-at-a-time
  5. Apply my regex to the original buffer, scanning for errors
  6. Save file and repeat for next file in the existing grep buffer.

This is not perfect because the regex applies to the original buffer as a whole, not only the matching lines, but so far it's a huge time saver!

Does anyone have a better workflow?

submitted by /u/tonicinhibition
[link] [comments]