This post explains How to remove the line that contains text in Notepad++. Use the Find and replace feature using regular expressions. the third way. For example, File content with the following content.

This is test content
This is test content4
This is a test of Java content5
This is test content
This is test content
This is test content

You want to remove the lines that contain the text java in the file.

Notepad++ provides find and replace features to edit and remove lines using regular expressions.

How to remove every line that contains text in Notepad++

There are multiple ways we can remove it.

One way is a bookmark feature.

  • Open the search menu > select Find Menu item, or use the shortcut (Ctrl + F)

  • It shows the Find window popup

  • Go to the tab mark, Select or check the following things. - Find what: java - Check Bookmark Line - Click on the Mark All Button, It does bookmark all the matched lines - Close Find window

  • Next, Go to Search > Bookmark > Remove Bookmarked Lines

  • It removes all the lines that are bookmarked in the text file.

Another way, use regular expression with the find and replace feature in Notepad++.

Following are steps

  • Open the search menu > select Replace Menu item or use the shortcut (Ctrl + H)

  • It opens the Find and Replaces popup

  • Please select the following options in the popup

    • Find what: .*java.*\r?\n
    • Replace With space(``).
    • Search Mode: Check the Regular Expression radio button
    • Click on the Replace All button, It removes the line that contains the text java in the text file and can be saved.
    • Following is the output
        This is test content
        This is test content4
        This is test content
        This is test content
        This is test content