Select Line EXCEPT Hard Return/NewLine

Help with writing and playing macros

Select Line EXCEPT Hard Return/NewLine

Postby seatrotter » Wed Aug 27, 2008 9:02 am

Anyone knows how to select a line of text excluding the hard return/newline (and not using drag selecting)? Normally, one could click the line-numbering at the left or triple-click, but such line selection would include the hard return/newline. I tried using combinations of modifier keys (Shift, Ctrl, Alt, etc) w/ no luck.

Another issue is the complete line selection w/ word-wrap enabled? Normally, w/ word-wrap enabled, automatic line selection would only be based on the line formed by the limitation of the GUI view, and not on the actual line terminated by a hard return/newline.

The first question is my primary concern.

Thanks
seatrotter
Newbie
 
Posts: 2
Joined: Thu Jul 10, 2008 1:11 pm

Re: Select Line EXCEPT Hard Return/NewLine

Postby Mofi » Wed Aug 27, 2008 9:55 am

How do you want to select the whole content of a line - with the mouse or with the keyboard?

With the mouse there is no other method than pressing primary must button, hold it and drag.
With the keyboard you have to go first to column 1 with key HOME which maybe must be pressed twice if the line starts with spaces/tabs and you have not enabled setting Home key always go to column 1 and you are currently not at the first non white-space character in the line. Next you have to press Shift+End to select from current cursor position to end of the line.

The best solution for you would be maybe to use a macro, stored in a macro file which is automatically loaded on startup of UE, with a hotkey associated to this macro for fast execution whenever you want to select whole content of a non empty line. The macro code would be:

HexOff
UnixReOff
Find RegExp Up "%"
IfNotFound
Top
EndIf
IfCharIs 13
ExitMacro
EndIf
IfCharIs 10
ExitMacro
EndIf
IfEof
ExitMacro
EndIf
Find RegExp Select "$"
IfNotFound
SelectToBottom
EndIf

You could use instead of the UltraEdit regular expression engine also the Unix or the Perl engine. Just replace UnixReOff by UnixReOn or PerlReOn and % by ^ and the macro will work with the other regex engines too. This macro always selects whole content of a line, independent on soft-wrapping on/off.

The macro property Continue if a Find with Replace not found or Continue if search string not found must be checked for this macro.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4055
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Select Line EXCEPT Hard Return/NewLine

Postby seatrotter » Wed Aug 27, 2008 1:14 pm

Thanks Mofi! That worked :)

The only problem now would be juggling w/ another MACRO (select line, transform thru another MACRO, copy, etc, repeat process) :(

I wished UE had a built-in keyboard/mouse command for this function, though (at the same time, addressing the second issue I raised). Or a toggle to allow inclusion/exclusion of hard break/newline. Some of my regular tasks involve copying content from one source and inserting it to another and one of these tasks is very straightforward (no need to understand the context of the content), thus allowing a macro to reformat and isolate lines of text. What I have recently discovered (right after I post this topic) is replace the hard break/newline w/ line feed [0x0D 0x0A -> 0x0C], allowing selection of whole line (either by clicking at the line number at left or triple-clicking at the line of text) w/o the hard break/newline.

Anyways...

Thanks again :)
seatrotter
Newbie
 
Posts: 2
Joined: Thu Jul 10, 2008 1:11 pm

Re: Select Line EXCEPT Hard Return/NewLine

Postby Bego » Wed Aug 27, 2008 1:19 pm

Hi seatrotter,

everything you need is built in UE.
With "PlayMacro ...." you can call other macros from within a macro.
There is LOOP and ENDLOOP to repeat things
You can switch between different clipboards with "CLIPBOARD [0-9]" for not overwriting current clipboard (0).

rds Bego
User avatar
Bego
Master
Master
 
Posts: 357
Joined: Wed Nov 24, 2004 12:00 am
Location: Germany


Return to Macros