Macro or search/replace expression to remove redundant spaces?

Find, replace, find in files, replace in files, regular expressions

Macro or search/replace expression to remove redundant spaces?

Postby rickcr » Sun Mar 26, 2006 10:33 pm

I'm messing around with pspad (a very good free editor http://www.pspad.com/en/screenshot.htm) and one thing it has that I really like is two quick menu options that

1) Remove Redundant blank lines
2) Remove Redundant space

The first one I figured out how to do with a macro I found while searching these forums (although I have to figure out how to get it to work in just selected text not the whole document).

Since I stink with regular expressions, can someone help with the latter - removing redundant spaces? That is if there is more than one space between a letter/word, I'd like it stripped out so that just one space remains. (I'd post this in the macro forum but not sure if it can maybe be done easily with search/replace?)

Thanks for any help.
User avatar
rickcr
Basic User
Basic User
 
Posts: 16
Joined: Tue Jul 19, 2005 11:00 pm

Re: Macro or search/replace expression to remove redundant spaces?

Postby rickcr » Sun Mar 26, 2006 10:46 pm

Duh.. I just modified my redundant blank lines macro and this works:

Top
TrimTrailingSpaces
Loop
Find " "
Replace All " "
IfNotFound
ExitLoop
EndIf
EndLoop


Stupid question though... How do I quickly execute different macros? It seems like I have to load one up first before I can run one? Shouldn't there be a way to easily choose to run any of your saved macros?
User avatar
rickcr
Basic User
Basic User
 
Posts: 16
Joined: Tue Jul 19, 2005 11:00 pm

Re: Macro or search/replace expression to remove redundant spaces?

Postby mrainey56 » Sun Mar 26, 2006 11:13 pm

From the Help:

The Macro Set Auto Load command allows you to specify a macro file that should be loaded automatically when UltraEdit is started.
User avatar
mrainey56
Master
Master
 
Posts: 212
Joined: Tue Jul 27, 2004 11:00 pm
Location: Spartanburg, South Carolina

Re: Macro or search/replace expression to remove redundant spaces?

Postby rickcr » Sun Mar 26, 2006 11:31 pm

Hmmm, isn't a macro file a collection of different macros? What I'm wondering is how do I execute the different macros I have in that file? It seems like I'm only able to execute the one macro that I see when I go to "edit macro." I must be missing something really simple, since I'm sure there is a way to quickly execute your user defined macros?
User avatar
rickcr
Basic User
Basic User
 
Posts: 16
Joined: Tue Jul 19, 2005 11:00 pm

Re: Macro or search/replace expression to remove redundant spaces?

Postby mrainey56 » Mon Mar 27, 2006 3:36 am

View > Views/Lists

Check the Macro List to make it visible - then double-click the macro you want to run. You can also use a toolbar button to toggle the visibility of the list. You can't assign individual macros to toolbar buttons, unfortunately.
User avatar
mrainey56
Master
Master
 
Posts: 212
Joined: Tue Jul 27, 2004 11:00 pm
Location: Spartanburg, South Carolina


Return to Find/Replace/Regular Expressions