• Login
Community
  • Login

Find line containing word and the next line below it

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
3 Posts 2 Posters 156 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.
  • D
    deleelee
    last edited by Jan 13, 2025, 1:23 AM

    I have an ini file that contains ‘tweaks’. They are entered in the file with a comment on one line explaining the tweak, then the tweak key/value on the next line.

    For example:

    ListSelectOnPasteInSamePath=1
    ListCheckboxSelectionMode=0
    ListCellsFirstLinesOnly=0
    ListAutoSelectFirst=1
    ; Tweak: right-padding of columns
    ListDetailsColumnsSpacing=3
    ; Tweak: left-padding of columns
    ListDetailsColumnsSpacingLeft=3
    ListsLineSpacing=2
    

    I assume I’ll need to use regex to do it but is it possible to do a Find All for only the tweak lines and their corresponding tweak key/value lines? Or by any other method if Find All isn’t the way to do it?

    The result for the example given would be:

    ; Tweak: right-padding of columns
    ListDetailsColumnsSpacing=3
    ; Tweak: left-padding of columns
    ListDetailsColumnsSpacingLeft=3
    
    T 1 Reply Last reply Jan 13, 2025, 1:43 AM Reply Quote 0
    • T
      Terry R @deleelee
      last edited by Terry R Jan 13, 2025, 1:44 AM Jan 13, 2025, 1:43 AM

      @deleelee said in Find line containing word and the next line below it:

      but is it possible to do a Find All for only the tweak lines and their corresponding tweak key/value lines?

      Well I’d go for a “Mark” with bookmark lines selected.

      Use:(?-s)^(?=.*tweak:)(.+\R.+\R) and click Mark All. All the tweak lines and corresponding following lines are bookmarked. Then you’d just copy the bookmarked lines to another tab.

      Terry

      D 1 Reply Last reply Jan 13, 2025, 1:59 AM Reply Quote 4
      • D
        deleelee @Terry R
        last edited by Jan 13, 2025, 1:59 AM

        @Terry-R said in Find line containing word and the next line below it:

        I’d go for a “Mark” with bookmark lines selected.

        Use:(?-s)^(?=.*tweak:)(.+\R.+\R) and click Mark All. All the tweak lines and corresponding following lines are bookmarked. Then you’d just copy the bookmarked lines to another tab.

        Thanks, Terry, perfect!!

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