• Login
Community
  • Login

Select/mark all lines which contain a certain pattern and add the line above

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
5 Posts 2 Posters 939 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.
  • S
    sgtsixpack
    last edited by Apr 14, 2020, 4:36 AM

    There is already a topic but I wanted to start a new thead to “add the line above”:
    https://community.notepad-plus-plus.org/topic/14704/select-mark-all-lines-which-contain-a-certain-pattern

    I’m not sure how to copy a line using the bookmark feature yet, but I want a bookmark to be added to every line above what I have already bookmarked as a result of edit>find>mark>bookmark line>mark all.

    A 1 Reply Last reply Apr 14, 2020, 12:08 PM Reply Quote 0
    • A
      Alan Kilborn @sgtsixpack
      last edited by Apr 14, 2020, 12:08 PM

      @sgtsixpack said in Select/mark all lines which contain a certain pattern and add the line above:

      how to copy a line using the bookmark feature

      Search menu > Bookmark > Copy Bookmarked Lines

      I want a bookmark to be added to every line above what I have already bookmarked

      You can’t do this based solely on the bookmarks. You can, however, craft a mark search expression that will bookmark a line of interest and the line above that one.

      A 1 Reply Last reply Apr 14, 2020, 5:51 PM Reply Quote 3
      • A
        Alan Kilborn @Alan Kilborn
        last edited by Alan Kilborn Apr 14, 2020, 5:54 PM Apr 14, 2020, 5:51 PM

        If you have already created YOURREGEX to mark data, if you want to bookmark the line it is on plus the line above, you could use a Find what box of:

        (?-s)^.*\R.*? and then append YOURREGEX to that.

        Example: Bookmark line containing foo and then line above it:

        Also: (?-s)\R.*?foo works but there will only be a bookmark on the “line above”, no red coloring of the text. I like the red coloring so I prefer the first version.

        1 Reply Last reply Reply Quote 2
        • S
          sgtsixpack
          last edited by Apr 14, 2020, 6:19 PM

          I just expanded my search to include the line above, not sure if this is what you meant. I don’t know about “craft an expression”. I also have no clue about your last reply. My problem is solved though so thanks.

          A 1 Reply Last reply Apr 14, 2020, 6:37 PM Reply Quote 0
          • A
            Alan Kilborn @sgtsixpack
            last edited by Alan Kilborn Apr 14, 2020, 6:38 PM Apr 14, 2020, 6:37 PM

            @sgtsixpack said in Select/mark all lines which contain a certain pattern and add the line above:

            I don’t know about “craft an expression”
            I also have no clue about your last reply.

            Sorry, I should have been more explicit.
            My comments were in regard to “Regular Expression” Search mode, which is typically what one is inferring when they ask “how can I manipulate data that is relative to some other data”.

            As you’ve probably discovered, you can, in Normal Search mode, bookmark the “line above” by making a selection that covers both lines, perhaps partially, and then pressing ctrl+f go get your text in the Find what box. You can then switch the Find window to the Mark tab and proceed with bookmarking.

            But if you do it that way, you aren’t truly doing “line above”, you’re doing “line of” and “line below”. :-)

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