Monday, September 29, 2008

Most Used UltraEdit Macros

There are some truly excellent macros on the UltraEdit extras page as well, but I am putting these up mostly for my own reference whenever I swap machines.

Updates:
24th May, 2009 - Added macro to close a html/xml tag, copied from UltraEdit forum post.
Monday 14 March 2011, 01:01:46 AM - reference to two other frequently used macros; for xml/html tag completion.

I use copy, cut and paste frequently. Most often I am cutting, copying and pasting just a single word (or token), so I wrote these macros to select a token and then copy or cup or paste. It saves me just that little bit of extra energy, since I don't have to select the token first. I added a bit of logic into each as well so that if I already have text selected, the macro will use that text instead of selecting the token under the cursor.

Copy token under cursor, or currently selected text. I map this to Alt+Z.

InsertMode
ColumnModeOff
HexOff
UnixReOff
IfSel
Copy
StartSelect
Else
SelectWord
Copy
StartSelect
EndIf

Cut token under cursor, or currently selected text. I map this to Alt+X.

InsertMode
ColumnModeOff
HexOff
UnixReOff
IfSel
StartSelect
Cut
Else
SelectWord
StartSelect
Cut
EndIf

Paste, replacing token under cursor, or currently selected text. I map this to Alt+Q.

InsertMode
ColumnModeOff
HexOff
UnixReOff
IfSel
StartSelect
Paste
EndSelect
Else
SelectWord
StartSelect
Paste
EndSelect
EndIf

This one isn't mine, but I don't remember where I got it from. Probably one of the truly excellent macros on the UltraEdit extras page.

Duplicate currently selected text or current line. I map this to Control+D.

ColumnModeOff
HexOff
Clipboard 9
ClearClipboard
IfSel
Cut
Paste
Paste
Find Up Select "^c"
Else
SelectLine
Cut
Paste
Key UP ARROW
Paste
PlayMacro 1 ""
EndIf
Clipboard 0

This one also isn't mine. I got it from an UltraEdit forum post: Automatically close tags.

Close most recent tag. I map this to Control+Shift+>.

InsertMode
ColumnModeOff
HexOff
UnixReOn
">"
Find Up "<"
IfFound
Clipboard 9
Key RIGHT ARROW
SelectWord 
Copy 
Find "<"
Find "<"
Key LEFT ARROW
"</"
Paste 
Find Up "<"
Key LEFT ARROW
Clipboard 0
Find ">"
Key RIGHT ARROW
EndIf
See my post UltraEdit macro for HTML/XML - auto-create closing tags for two other frequently used macros - these for completing HTML/XML tags.