Selecting text while doing a search in a macro
-
In Ultraedit (another text editor) I was able to record a macro, do a search and hold the shift key while I did this to highlight all the text from the point I was at to the search result, Then I could hit the delete key to quickly eliminate all the unwanted text. Is this possible with Notepad++. Everytime I try it, it doesn’t work.
-
There’s no way, as far as I know, to join the Shift+select with a search result to highlight a large block of text. Then again, there’s no need.
Let’s say you’ve got multiple lines of text, with the caret just after the
|
character in the text:This is long text |that goes on and on for many lines this is just an example. And then it's over.
Let’s say you want to select everything from that point to the end of the word
example
in the text.- FIND =
(?s).*?example
- REPLACE = empty
- Find Next will highlight from the caret through the end of the word
example
- Replace will delete that
And clicking in a new place, and either doing
F3
-then-Delete
or FindNext-then-Replace again will delete the next occurrence from the second caret position. And so on.And if all you care about is the highlighting, the F3 (Search > Find Next) will select the text from the current caret to the next instance of
example
, andDelete
will delete it, even without the Find/Replace dialog being still open - FIND =
-
Alternatively: click Edit > Begin/End Select with the caret after the
|
(that is, wherever you want the selection to start). Then do a normal Find or Incremental Search or Find Next or what have you to find the “end” of the block you want to select, and then do Edit > Begin/End Select again, which will select that whole range of text, even if you do a simple search without the fancy regex syntax. You can use Settings > Shortcut Mapper to assign a key to the Begin/End Select, so that way you don’t have to use the menu every time.