grepedit
Sometimes we grep for something in a bunch of files, and then we want to make edits to the lines that were returned from the grep. It's a hassle in most editors to open all the files and find all the lines. grepedit puts the match lines in a temp file for easy editing all at once.
The cmdline arguments to grepedit are the same as those to grep. Do not use arguments that alter the output line format; -C is ok.
grepedit also reads the following arguments:
--sort-text sort lines by the text part of the line (this probably doesn't make sense with -C)
Install
pip install grepedit
Download version 2.0 (2022-04-05) (py3 support- thanks Benjamin!)
Download version 1.0 (2005-10-09)
Screenshots
Run grepedit on itself and setup.py:
% grepedit the *
Edit the result lines in vi (according to $EDITOR):
grepedit:3:"""sometimes we grep for something in a bunch of files, and then we grepedit:4:want to make edits to the lines that were returned from the grep. It's grepedit:5:a hassle to edit all the files; this program puts the match lines in a grepedit:8:EDITOR is used on the temporary file. grepedit:10:The cmdline arguments to grepedit are the same as those to grep. Do grepedit:11:not use arguments that alter the output line format; -C is ok. grepedit:13:grepedit also reads the the following arguments: grepedit:15: --sort-text sort lines by the text part of the line (this probably grepedit:100: print "%s:%s has changed since the grep command ran- not modifying this line" % key setup.py:6: description="edit lines the result of a grep and modify the original files", ~ ~ ~ "/tmp/grepedit_IOLHsa" 10 lines, 792 characters
grepedit reports what changes it made:
% grepedit the * no changes made in file setup.py grepedit:13 substituting new line %
Related
emacs occur-edit-mode, new in emacs24 (a short howto)
hide-lines.el similar thing, but for working on one buffer in emacs
all.el --- Edit all lines matching a given regexp (in emacs)