emacs/var/elfeed/db/data/d5/d5b173af1bf76a41805729ed339b33e52be60343
2022-01-03 12:49:32 -06:00

1 line
2 KiB
Plaintext

<!-- SC_OFF --><div class="md"><p>I recently discovered an awesome capability of Emacs, where I can use <code>occur</code> to pull all matching lines into a split window and press <code>e</code> to enter <code>occur-edit-mode</code>. In this mode I can do things like <code>replace-string</code> to modify all of the matching lines in my original buffer.</p> <p>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.</p> <p><strong>Shortcoming</strong></p> <p>This mode does not currently have <code>evil</code> bindings. I can <em>test</em> my regex by using <code>evil-ex</code> - I get my lovely red strike-through and expected changes, but entering <code>evil-ex</code> seems to disable the edit capabilities of the <code>occur-edit-mode</code> and I&#39;m left with a read-only buffer.</p> <p><strong>Current Workflow</strong></p> <p>I&#39;m modifying 20+ large files with many rewrite rules and have come up with the following:</p> <ol> <li>Use <code>eshell</code> to create a grep buffer across all relevant files.</li> <li>Test my regex using <code>:</code> (<code>evil-ex</code>) in the grep buffer</li> <li>Verify that all buffers will change as desired.</li> <li>Jump to each matching file from the grep buffer one-at-a-time</li> <li>Apply my regex to the original buffer, scanning for errors</li> <li>Save file and repeat for next file in the existing grep buffer.</li> </ol> <p>This is not perfect because the regex applies to the original buffer as a whole, not only the matching lines, but so far it&#39;s a huge time saver!</p> <p>Does anyone have a better workflow?</p> </div><!-- SC_ON --> &#32; submitted by &#32; <a href="https://www.reddit.com/user/tonicinhibition"> /u/tonicinhibition </a> <br/> <span><a href="https://www.reddit.com/r/emacs/comments/qz23lm/evil_regex_workflow_in_greplike_buffers/">[link]</a></span> &#32; <span><a href="https://www.reddit.com/r/emacs/comments/qz23lm/evil_regex_workflow_in_greplike_buffers/">[comments]</a></span>