How to delete lines and move them up accordingly.

Tool for Search and Replace across multiple files.
Post Reply
User avatar
Jojo

How to delete lines and move them up accordingly.

Post by Jojo »

I would like to delete certain lines ended with a carriage return and move them up accordingly. These lines are found in 75 files in the same directory.

Example BEFORE:

1. This is Line 1
2. This is Line 2
3. This is Line 3

Now, I would like to delete "2. This is Line 2" and get the whole thing to move up and adjust accordingly as shown below.

Example AFTER:

1. This is Line 1
3. This is Line 3
User avatar
Fool4UAnyway

Post by Fool4UAnyway »

If your lines contain static text, that is, are the same for each occurrence, you could just perform a simple find and replace operation, by just typing the text to find and the text to replace as stated above.

If you want to use a regular expression, it would be like this:

Find:
(regexforline1\r\n)regexforline2\r\n(regexforline3)

Replace by:
$1$3

You simply look for three lines and re-place the first and the third, which in effect removes the second line including its newline character (CR LF) and thus "moves up" anything below it.
Post Reply