Remove empty lines

General questions about using TextPad

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

Post Reply
Xover
Posts: 7
Joined: Fri Apr 23, 2004 3:33 pm

Remove empty lines

Post by Xover »

Hi,

I'm trying Textpad now since 1 week and I like it. However there's one problem I have.
When I write code, Textpad automatically sets the whitespaces or tabs when I jump to the next line. I would like to remove these whitespaces and tabs from empty lines with some regexp or so because if there are a lot of them it makes the files a lot bigger. Is that possible? An example of what I mean:

Code: Select all

if ($foo) {
                  <---- here are some whitespaces and/or tabs, that I dont need.
  echo 'test';
}
User avatar
s_reynisson
Posts: 939
Joined: Tue May 06, 2003 1:59 pm

Post by s_reynisson »

TP includes a macro called Delete Blank Lines, goto Configure->Preferences->Macros to add it to the Macro menu, if you want you can add a keyboard shortcut for it, goto Configure->Preferences->Keyboard.
You might also want to look at Configure->Preferences->Document Classes->*Your Class*->Tabulation, maybe even for the Default class. You will also find the Help file ... err ... helpful on these topics. HTH
Then I open up and see
the person fumbling here is me
a different way to be
User avatar
talleyrand
Posts: 624
Joined: Mon Jul 21, 2003 6:56 pm
Location: Kansas City, MO, USA
Contact:

Post by talleyrand »

On a per document basis, right click the background, select preferences:
Check Strip Trailing Spaces to remove excess trailing WS
Uncheck Automatically Indent Blocks

To apply changes permanently, do the same to the document class.
I choose to fight with a sack of angry cats.
Xover
Posts: 7
Joined: Fri Apr 23, 2004 3:33 pm

Post by Xover »

@s_reynisson: that's not exactly what I want. I want to keep the empty lines, but I want to make them empty. Because of the automatic indent of Textpad there are sometimes many spaces and/or tabs. But I don't want to deactivate the automatic indent.
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

Then replace
line start followed by any amount of space or tab followed by line end with nothing::

search for
^[ \t]+$

replace by nothing

Regex must be switched on.


Alternatively you could set

Configure - Preferences - Document Classes - your document class - Strip trailing white spaces when saving

But this would affect not-empty lines as well.
Xover
Posts: 7
Joined: Fri Apr 23, 2004 3:33 pm

Post by Xover »

Thanks, that's exactly what I was searching for!
Post Reply