In this tutorial, we will learn how to delete specific lines in Notepad++ or rather all lines that contain a string. Thus, we will be able to purge a file in a few seconds. Recently, I used this method to clean up a log file by removing all lines that contained a specific IP address. This is just one example, and the use cases are limitless…
Before you begin, I recommend that you make a copy of your file. Thus, in case of mishandling, the contents of your file will not be lost.
II. Mark rows to delete
First of all, you have to open the file in question and click on “Research” in the menu then on “To mark“. You can also use the keyboard shortcut “CTRL + M“. The hotkey can be useful if you need to use this function regularly.
A window opens, in the “Research” indicate the value to look for. This is a benchmark value, because all rows that contain this value will then be deleted. Check the option “Add a bookmark on the line” and validate. For my part, there are still 85,338 lines to mark (and therefore to delete)!
In the file, a bookmark (blue dot on the left) is added on each line that contains the value. Thereby, these lines are easily identifiable.
III. Delete marked rows
To remove bookmarked rows is easy, because there are a native function in Notepad++ which allows you to do it! Always in the menu”Research“, sous “Signet“, click on “Delete marked rows“. You can also do the opposite to keep only the rows that contain this value by clicking on “Delete unmarked rows“.
Voila, the lines marked with a bookmark are deleted from your file! All that remains is to save. Thank you Notepad++ for this very practical (and native) function.
#remove #specific #rows