delete excessive blank lines...

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
agent86
Posts: 18
Joined: Wed Apr 26, 2006 2:59 am
Location: SF Bay Area

delete excessive blank lines...

Post by agent86 »

I have documents that contain 2 blank lines in a row. When it occurs, I would like to erase the second blank line.

For example:

Now is the time


for all good men to...

**becomes**

Now is the time

for all good men to...
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

Search for: \n\n
Replace with \n

Need checkmark in box to Use Regular Expressions
Hope this was helpful.............good luck,
Bob
agent86
Posts: 18
Joined: Wed Apr 26, 2006 2:59 am
Location: SF Bay Area

great. that works, but how...

Post by agent86 »

I now see there are lines with just spaces in them from 2-4, maybe more. What do I do if the adjacent lines just have spaces. It appears to be 2 blank lines in a row but there are only spaces. Can it verify if there are spaces only and remove the second line?

For example:


Now is the time for all good men
[space][space]
[space][space]space][space]
to come to the aid of the party

***becomes***
Now is the time for all good men
[space][space]
to come to the aid of the party
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

Your words are not matching your example. Your words say to remove the second line, but the example removes the first line.

The following will remove all Space, tab, vertical tab, return, line feed, form feed that start the line and continue/mix till the end of the line. This takes care of all white space and just leaves a return

Search for:^[[:space:]]*\n^[[:space:]]*\n
Replace with: \n

So that this:
Now is the time for all good men
[space][space]
[space][space]space][space]
to come to the aid of the party

***becomes***
Now is the time for all good men

to come to the aid of the party
=========================
If you really want the "blank" line to have two spaces then insert two spaces in front of the \n that is mentioned above.
Replace with " \n"
Hope this was helpful.............good luck,
Bob
Post Reply