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



  • 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.



  • @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



  • 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}


Log in to reply