I have following file:
aaaa1
bbbb
cccc
dddd
aaaa2
eeee
ffff
aaaa3
I would like to perform 'narrowing search', so if I search for aaaa
my original buffer will become:
aaaa1
aaaa2
aaaa3
Is there any tool for doing such thing ?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.
Sign up to join this communityI have following file:
aaaa1
bbbb
cccc
dddd
aaaa2
eeee
ffff
aaaa3
I would like to perform 'narrowing search', so if I search for aaaa
my original buffer will become:
aaaa1
aaaa2
aaaa3
Is there any tool for doing such thing ?
The loccur
package, also available on Melpa, does exactly what you want.
From its github page:
loccur
is a minor mode for Emacs acting likeoccur
but without creating a new window. It just hides all the text except lines containing matches for a given regexp.
So you can do occur
or use something fancier like helm-swoop
to bring up a narrowed search buffer depending on your criteria. Both of these modes can then edit the search buffer and the results can be saved to the original buffer. The narrow functions are really just for contiguous lines of text (by region, defun or page).