How to eliminate white space?

General questions about using TextPad

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

Post Reply
tommt
Posts: 4
Joined: Sun Dec 07, 2003 2:13 am

How to eliminate white space?

Post by tommt »

Using the "VIEW>VISIBLE SPACES" options, I opened some of my files and noticed some white spaces that are not needed, like in this screenshot:

Image

How can I eliminate those unneeded white spaces? I want to eliminate the white spaces BUT keeping the indenting, is it possible?

thanks
User avatar
CyberSlug
Posts: 120
Joined: Sat Oct 04, 2003 3:41 am

Post by CyberSlug »

A regular expression search and replace can remove whitespace from the end of each line. Click Search, Replace then fill in the "Find what' field with [[:blank:]]+$ and leave the other field blank. Make sure the "use regular expressions" box is checked.

How the regular expression works:
[[:blank:]] matches a tab or a space
+ matches one or more occurances of the previous item
$ constrains the searches to the end of the line

Hope that helps

Addendum: You can download a "Reformatting" macro that does this
http://www.textpad.com/add-ons/macros.html
tommt
Posts: 4
Joined: Sun Dec 07, 2003 2:13 am

Post by tommt »

Thanks for the addendum, seems what I need! Gonna try it now,

although, by your explanation, [[:blank:]]+ would remove the tabs as well, no? I'd like to remove spaces only while keeping the tabs.

thanks!
User avatar
CyberSlug
Posts: 120
Joined: Sat Oct 04, 2003 3:41 am

Post by CyberSlug »

In that case, try [ ]+$

See "How to Use Regular Expressions" in TextPad's help file for more info.
Post Reply