Monday, August 02, 2010

Autohotkey mapping for a find with "Highlight All Items Found" option in UltraEdit

One of the relatively new features I like in UltraEdit is the "Highlight All Items Found" option in the Find dialog - it will yellow highlight all instances of the thing you want to find in the current document. Unfortunately, this is not quite as good as the same thing in Notepad++ and Eclipse. In Notepad++ and Eclipse, you activate this just by double clicking on a token i.e. double click on a word and all instances of it in the same document will be highlighted.

Worse, Ultraedit doesn't have any way to make a keyboard shortcut for a find with the "Highlight All Items Found" option, nor can it be recorded/used in a macro. So, I have created a rough work-around using Autohotkey. The script below binds control+h to do a find against whatever text you currently have selected and uses the "Highlight All Items Found" option to do so. Also note that the control+h only does this when you are actually in UltraEdit i.e. doesn't affect control+h in any other programs.

; - UltraEdit macros
#IfWinActive, UltraEdit ; Mappings defined here work only for UltraEdit
   ; - Ultraedit: Find using "Highlight All Items Found" option.
      WinWait, Find,
      IfWinNotActive, Find, , WinActivate, Find,
      WinWaitActive, Find,
      Send, {ALTDOWN}i{ALTUP}{ENTER}
#IfWinActive ; Subsequent mappings now affect all windows.

This is just one AutoHokey function I have defined in a single Autohotkey utilities script that gets loaded through my Windows Startup directory so that it is always available. For others, check out this SuperUser post: Most useful AutoHotkey scripts.