Page 1 of 1

Erasing blank lines

Posted: Mon Dec 29, 2008 2:13 am
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!

Posted: Mon Dec 29, 2008 7:20 am
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".

Posted: Mon Dec 29, 2008 9:31 pm
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

Posted: Mon Dec 29, 2008 11:06 pm
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
-----------------------------------------

Posted: Tue Dec 30, 2008 2:21 am
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

Posted: Tue Dec 30, 2008 3:13 am
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.

Posted: Tue Dec 30, 2008 9:40 am
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?

Posted: Tue Dec 30, 2008 11:11 am
by ben_josephs
Find what: ^[ \t]*\n
Replace with: [nothing]

[X] Regular expression

Replace All

Posted: Tue Dec 30, 2008 9:41 pm
by xavekinho
This ends the discussion! :)
Thanks!

Posted: Wed Dec 31, 2008 9:23 am
by agnul
Or you could search for
^[[:blank:]]*\n
saving you the 'hassle' of remembering what's a white space :lol:

Posted: Wed Dec 31, 2008 1:16 pm
by xavekinho
Tip noted. thanks a lot too!