Delete whole line based on search
I have a file with a few hundred lines. There is a specific text in some lines which can be used to identify which lines to remove.
I tried recording a macro by searching for the word “KRA” and then deleting the entire line but when I run the Macro, it only removes the word KRA from the lines.
I’m very new to macros so I can’t really troubleshoot it, has anyone recorded a macro like this previously and can provide some suggestions on how to delete the whole line based on the search result or if the line has a specific word in it?
A better option is to use the “Mark” feature. So under main menu “Search” look for Mark.
On the Find What field type in what you are searching for. You can use the search mode as “Normal”, that way it means you are explicitly searching for some text, rather than using a regular expression to search.
Make sure the “bookmark line” is ticked, also have “wrap around” ticked. Then click on the “Mark All” button. Now every line that has that text in it will have a blue circle at the start of the line (default marker) denoting that line has the text.
Before removing the lines, you may want to check some to be certain they haven’t picked any lines you did NOT want deleted.
Once confirmed use the main menu “Search”, then “Bookmark” then “Remove Bookmarked Lines”.
This is a far easier method than using a regex (regular expression) or using a macro to remove a line.
Thanks Terry. That’s exactly what I was looking for. Just couldn’t see the Remove Bookmarked Lines option where I looked.
Appreciate the quick response.