Erasing blank lines

General questions about using TextPad

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

Post Reply
xavekinho
Posts: 9
Joined: Sun Oct 19, 2008 4:22 am

Erasing blank lines

Post by xavekinho »

Hi, I like the EditDelLine command, but is there a similar command to erase all the blank lines of the active document?

Also, is there a simple command to erase all white spaces in the end of lines? This is because sometimes I paste a list in a txt file, but the source had one or a couple of blank spaces at the end of each line.

Thanks in advance!
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

1.) replace

Code: Select all

\n\n
by

Code: Select all

\n
(Regex!) repeatedly till it finds no more.

2.) there is an option to strip trailing whitespace on saving. You can set this per document class, go to Configure - Preferences - Document Classes - <yourdocumentclass>, then in the righthand side of the dialog search for the checkbox "Strip trailing spaces from lines when saving".
xavekinho
Posts: 9
Joined: Sun Oct 19, 2008 4:22 am

Post by xavekinho »

Could not find such Regular Expression! :( A piece of the text I was trying to apply was:

Code: Select all

        4  Standstill
        2  Umezawa's Jitte
//  29 other spells


//  Sideboard

SB:  3  Annul
SB:  1  Blue Elemental Blast
SB:  3  Engineered


PostPosted: Mon Dec 29, 2008 7:20 am Post subject:
1.) replace
Code:
\n\n
by
Code:
\n
(Regex!) repeatedly till it finds no more.

2.) there is an option to strip trailing whitespace on saving. You can set this per document class, go to Configure - Preferences - Document Classes - <yourdocumentclass>, then in the righthand side of the dialog search for the checkbox "Strip trailing spaces from lines when saving".

Thanks!! :D
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

To replace all trailing spaces at the end of line:

Search for: _*\n
Replace with: \n
( Using "_" to represent the space character )

---------------------------

To replace all blank liines:
Search for: \n\n
Replace with: \n

===========================================
Use the following settings:
-----------------------------------------
[X] Regular expression
Replace All
-----------------------------------------
Configure | Preferences | Editor
[X] Use POSIX regular expression syntax
-----------------------------------------
Hope this was helpful.............good luck,
Bob
xavekinho
Posts: 9
Joined: Sun Oct 19, 2008 4:22 am

Post by xavekinho »

To replace all blank liines:
Search for: \n\n
Replace with: \n
Like I said, for some reason it's not finding that regex..
To replace all trailing spaces at the end of line:

Search for: _*\n
Replace with: \n
( Using "_" to represent the space character )

Thanks!! :D
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

Maybe the blank lines are not blank?

Have you turned on visibility for all characters? Maybe spaces or tabs are there?

Have you tried to remove trailing spaces on the "blank lines" first? Remove the blank spaces on all lines, then try searching for \n\n. And make sure there are no leading/trailing spaces in the search phrase \n\n.
Hope this was helpful.............good luck,
Bob
xavekinho
Posts: 9
Joined: Sun Oct 19, 2008 4:22 am

Post by xavekinho »

Bob Hansen wrote:Maybe the blank lines are not blank?

Have you turned on visibility for all characters? Maybe spaces or tabs are there?

Have you tried to remove trailing spaces on the "blank lines" first? Remove the blank spaces on all lines, then try searching for \n\n. And make sure there are no leading/trailing spaces in the search phrase \n\n.
Hmm, that's it! There are actually tab spaces! But they aren't visible, so is there another trick to get get rid of all blank lines, including the ones with white spaces or tabs?
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Find what: ^[ \t]*\n
Replace with: [nothing]

[X] Regular expression

Replace All
xavekinho
Posts: 9
Joined: Sun Oct 19, 2008 4:22 am

Post by xavekinho »

This ends the discussion! :)
Thanks!
agnul
Posts: 21
Joined: Tue Feb 10, 2004 9:42 am
Location: Italy

Post by agnul »

Or you could search for
^[[:blank:]]*\n
saving you the 'hassle' of remembering what's a white space :lol:
xavekinho
Posts: 9
Joined: Sun Oct 19, 2008 4:22 am

Post by xavekinho »

Tip noted. thanks a lot too!
Post Reply