Community
    • Login

    Search result with e.g. 5 lines before and 5 lines after result

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 3 Posters 2.2k 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.
    • Korea VisitK
      Korea Visit
      last edited by

      hallo,

      is there any function in Notepad ++ where you are able to search in files for an expression.
      As result should be given e.g. 5 lines before result and 5 lines after result.
      Does anyone has an idea if possible.

      thanks.

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

        @Korea-Visit

        You will need to expand on your description considerably if you expect a solution.
        Currently the statement “search in files for an expression” could mean either supply a folder and search all files for something, or maybe the file you want to search is currently loaded in Notepad++ (NPP).
        Then your other statement "As result should be given e.g. " also begs the question, what do you want to do with the result. Do you only want to highlight it, or do you want to edit it, or maybe remove all other data from the open file and just leave the 11 lines (5 before + line with expression + 5 lines after) for each instance found.

        Terry

        1 Reply Last reply Reply Quote 3
        • Alan KilbornA
          Alan Kilborn
          last edited by

          My interpretation is that the OP really wants to see 5 lines of context before/after hits for his search. The LineFilter plugin can do it. Or the following regex search can, if one is searching for the word text (as just an example):

          Find what: ^(?:.*\R){5}.*text.*\R(?:.*\R){5}

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