Search code examples
replacenotepad++line-breaksblank-linepreserve

Preserve line breaks when Removing Bookmarked Lines


I have a large text file with several lines and I want to replace several of those lines with a blank line. I used regex to search for certain patterns, marked and bookmarked them, then used:
Search > Bookmark > Inverse Bookmark to hopefully highlight those strings I want to blank-replace.

However, I find only Remove Bookmarked Lines and Remove Unmarked Lines, both of which strip line breaks in the text file.

Is there a way to preserve line breaks while replacing those inverse-bookmarked lines with a blank line?

Sample text (lines 1 and 6 are bookmarked for replacing with an empty/blank line):

1 Oroc-Osoc PS
2 Osiao Paglingap Elementary School
3 Osmena  E/S
4 Osmena Elementary School
5 Osmena ES
6 Pablo .M. Conag CS

Expected output:

1 
2 Osiao Paglingap Elementary School
3 Osmena  E/S
4 Osmena Elementary School
5 Osmena ES
6 

Solution

  • You can do any of those alternatives:

    Alternative A)

    1. Copy a space to the clpiboard with Control+C for example
    2. Do: Search => Bookmark => Replace bookmarked lines

    If you don't want to leave a space at the beginning of the lines use Alternative B)

    1. Copy something that cannot repeated on the whole file to the clipboard <<<EOL>>> for example.
    2. Do: Search => Bookmark => Replace bookmarked lines
    3. Replace <<<EOL>>> by \r\n be sure to mark extended match