Show only lines that contain a given search argument
-
Hey guys!
How could I make notepad++ show on the screen only lines that contain a certain search argument? For example, all lines of the text being edited that contain the expression “move zero” (without the quotation marks).
There are editors that even allow the use of and/or.
“move zero” or “move 9” for example or
“move zero” and “move 9”. -
The answer depends on the specific use case, i.e. what you want to achieve.
In general, there are ways to get rid of “unwanted lines”, but if you are looking for a built-in way to filter a view of a document and edit that document in that filtered view, then there is not. -
I don’t know that it is really needed.
I’d use Find All in Current Document.
Then you have a panel (Search results) that shows you what you are asking for, with an easy “jump to” the real lines that are shown in it. -
I had never realized. This suggestion of yours really meets what I needed. Better than that, only the search results appear directly on the main screen or in a tab instead of a panel with a few lines at the bottom of the screen.
But that’s right, I recognize that your suggestion solved my problem.
Thank you very much. -
@nightrider43 said in Show only lines that contain a given search argument:
only the search results appear directly on the main screen or in a tab instead of a panel with a few lines at the bottom of the screen.
You can resize the panel. Or even pop it out into its own window (see the Panel Mechanics description in the Online User Manual)
-
@nightrider43 I use the “Mark” tab in the search dialogue:
Find what: (whatever you search)
Bookmark line
Wrap around
(if necessary further settings)
Click on “Mark All”, then “Close”.Goto “Search” > “Bookmark” > “Cut (or Copy) Bookmarked Lines” and paste it whereever you want.
That’s an alternative way to “Find All in Current Document” - and you don’t need to remove the prefix "Line nn: " in the result list.
-
Just noting that the OP didn’t express a desire for copying lines of interest to another place, but simply “showing lines” as per the title of the thread.
But like my post earlier, maybe your post gives others ideas about what they didn’t know they could do.
-
@Petra-Handwerg said in Show only lines that contain a given search argument:
…an alternative way to “Find All in Current Document” - and you don’t need to remove the prefix "Line nn: " in the result list.
And more of what you maybe didn’t know: If you right-click in the Search results window, the popup menu will have a Copy choice and a Copy Lines choice – Copy will get the “Line nn:” info with the line data, whereas Copy Lines will get ONLY the line data.
-
@Alan-Kilborn said in Show only lines that contain a given search argument:
And more of what you maybe didn’t know: If you right-click in the Search results window, the popup menu will have a Copy choice and a Copy Lines choice – Copy will get the “Line nn:” info with the line data, whereas Copy Lines will get ONLY the line data.
Oh, great tip, thank you! I wasn’t aware that the result section has its own context menu.
Good to know!