Community
    • Login

    Selecting text while doing a search in a macro

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 957 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Maribel PilotoM
      Maribel Piloto
      last edited by

      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.

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Maribel Piloto
        last edited by PeterJones

        @Maribel-Piloto ,

        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
        1. 7bd529b8-2a88-4e78-93fa-8299b11c2e63-image.png
        2. c975e07a-0e40-46cf-823a-eafd9a1e9571-image.png
        3. 4da42408-64f5-4144-9491-0b718cbccb2a-image.png

        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, and Delete will delete it, even without the Find/Replace dialog being still open

        PeterJonesP 1 Reply Last reply Reply Quote 2
        • PeterJonesP
          PeterJones @PeterJones
          last edited by

          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.

          1 Reply Last reply Reply Quote 1
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors