Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    How to find text, then delete the next line?

    Help wanted · · · – – – · · ·
    3
    9
    868
    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.
    • Scott DuBose
      Scott DuBose last edited by

      How can I find text, then delete the next line? I know how to find the text, but how do I tell N++ to then delete the line following?
      Or… find text, bookmark the line following?
      Thanks…

      1 Reply Last reply Reply Quote 0
      • Terry R
        Terry R last edited by

        @Scott-DuBose said in How to find text, then delete the next line?:

        How can I find text, then delete the next line?

        You haven’t explained if you are finding text through a regular expression (regex) or just by searching for that exact text or manually.

        The easiest method of removing a following line is through a regex. It will allow you to search using a search pattern, then remove the folowing line. Example is

        line here
        line here
        this line is what i want to find
        this line I want to delete
        

        Regex used would be similar to (using the Replace function):
        Find What:^.*i want to find\R\K^.*\R
        Replace with:empty field here

        So the regex uses the first portion to find a line ending in “i want to find” followed by a carriage return/line feed. It then promptly discards that selection (using the \K) and then selects the complete line following and replaces it with nothing, so deleting it. If the following line is empty it will still work.

        Terry

        Scott DuBose 1 Reply Last reply Reply Quote 3
        • Scott DuBose
          Scott DuBose last edited by

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • Scott DuBose
            Scott DuBose last edited by

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • Scott DuBose
              Scott DuBose @Terry R last edited by

              Thanks, it worked! Example:

              Message 34159
              34158
              2009-01-02 09:40:51

              I Find: Message.?\R\K^.\r

              Which then selects 34158 on the second line.

              When I enter nothing in the “Replace with” field, and clicked " Replace" - it did nothing. But when I clicked “Replace All,” it cleaned all the lines I wanted gone. Thanks for your help…

              Scott DuBose 1 Reply Last reply Reply Quote 0
              • Scott DuBose
                Scott DuBose @Scott DuBose last edited by

                Why are asterisks being removed from my post? Regex used isalt text

                Alan Kilborn 1 Reply Last reply Reply Quote 0
                • Alan Kilborn
                  Alan Kilborn @Scott DuBose last edited by

                  @Scott-DuBose said in How to find text, then delete the next line?:

                  Why are asterisks being removed from my post?

                  Because this forum uses a form of “markdown” and the asterisk is a character that has special meaning. It adds italics if you wrap a word with 2 asterisks.

                  The way to get it to NOT interfere with your text is to use backticks around your text; then what you type will appear like this and will not be messed with.

                  1 Reply Last reply Reply Quote 1
                  • Scott DuBose
                    Scott DuBose last edited by

                    Thanks, had to look up backtick… :-) Found it!

                    1 Reply Last reply Reply Quote 2
                    • Scott DuBose
                      Scott DuBose last edited by

                      Thanks, in a document with 124,000 lines, this deleted 20,000 lines in about 10 seconds. Notepad++ is so awesome. Shoutout to Don Ho

                      1 Reply Last reply Reply Quote 2
                      • First post
                        Last post
                      Copyright © 2014 NodeBB Forums | Contributors