BigDiver

Dive away, explore the net…

Archive for the ‘Keyword Expansion’ Category

Configure Home/End Key Bidings on Mac OS X

without comments

Hi I feel that thisĀ  a prety common request: Bind the Home/End keys to move to the beginning and end of lines respectively.

In Mac OS X (10.5 and 10.6) some applications use the Cmd-Rigt and Cmd-Left to perform these actions but, call me old fashioned, I like to use Home and End instead.

It is actually very easy to change the Cocoa Key bindings for any user under Mac OS. Just follow these steps:

  1. Create a file called DefaultKeyBinding.dict in ~/Library/KeyBindings directory
    mkdir ~/Library/KeyBindings
    cd ~/Library/KeyBindings
    touch DefaultKeyBinding.dict
  2. Edit your DefaultKeyBinding.dict file so it contains:
    {
    /* home */
    "\UF729"  = "moveToBeginningOfLine:";
    "$\UF729" = "moveToBeginningOfLineAndModifySelection:";
    
    /* Cmd-Left */
    "@\UF702"  = "moveToBeginningOfLine:";
    "$@\UF702" = "moveToBeginningOfLineAndModifySelection:";
    
    /* Cmd-Right */
    "@\UF703"  = "moveToEndOfLine:";
    "$@\UF703" = "moveToEndOfLineAndModifySelection:";
    
    /* end */
    "\UF72B"  = "moveToEndOfLine:";
    "$\UF72B" = "moveToEndOfLineAndModifySelection:";
    
    /* page up/down */
    "\UF72C"  = "pageUp:";
    "\UF72D"  = "pageDown:";
    }
  3. Restart the Cocoa Application.

This example works very well with TextMate.

In order to bind other keys you need to find their Scan code, and you can use the following modifiers
For more information please check this article

Written by bigdiver

September 11, 2009 at 7:26 pm

E-TextEditor is TextMate on Windows!

with 4 comments

Finally a TextMate port for Windows is out!

Well sort of any way.

“E-TextEditor” is a TextMate equivalent for Windows, it supports all of TextMate’s bundles and most of its functionality. If you run Windows and salivate over the Mac fellows, when you watch the Rails screencasts, here’s your chance to get even!

Check it out at http://www.e-texteditor.com/

Written by bigdiver

January 1, 2008 at 5:58 am

UltraEdit Tab Expansion Macros

without comments

It is a shame that for the moment UltraEdit and UEStudio do not support TAB keyword expansion. After testing it for a while i found the editor to be really good but lacking, in my view, this extremely important feature.

After messing around with the configuration for a while, trying the auto completes, templates, etc, i found none of these features really didn’t do what i wanted. Expand a keyword as soon as one presses the TAB key, leaving the cursor at the proper position for continuing your edit as fast as possible.

so i started playing around with the macros and after much head banging and trial and error
(mostly error) I wrote the set of macros attached to this post that do what I wanted.
I don’t know the limitations on the number of commands per macro, or if this is the best way to achieve the proposed goal, so if you find a way to improve this please be my guest, just let everybody else know about it.

The perfect solution would be for UltraEdit to support this feature, by reading a text file with keywords and their expansions or something like that, but for the moment you can use this workaround.

The macros assume that you have UltraEdit configured to automatically insert the closing Prentiss, or curly braces (Advanced->Configuration->IDE->InteliTips->Miscellaneous)
And Smart Placement of “}” when placed automatically is also checked.

After loading the macros assign the TabExpand macro to the TAB key. If you do this remember that the autocomplete feature will be disabled. You can always use a different key thought.

The structure of the macros is simple:

create a new macro for each tab keyword expansion you want. call it TE_keyword

write the macro as follows

InsertMode
ColumnModeOff
HexOff
PerlReOn
Find MatchWord Select “your_keyword
Replace SelectText “your_expanded_text
IfFound
PlayMacro 9 “TE_Left”
EndIf

replace the your_keyword with the keyword you like and do the same with your_expanded_text, which is the text that should be placed after the keyword is “expanded”.

After the IfFound command you can place more macro instruction, either to place the cursor properlly or insert more text.

to activate the newly created macro modify the TabExpand macro and add the following code to it:

PlayMacro 1 “TE_keyword”
IfSel
Else
ExitMacro
EndIf

The IFSel is a hack in order for the macro to exit if there was any replacement done. meaning the keyword was expanded in the previous call to PlayMacro. This is not very beautiful but works. If you know of a better way to do this let me know…

Please take a look at all the predefined macros in the file for more details on how to use the TabExpand “system”

Download the macro file from here.

Written by bigdiver

January 25, 2007 at 6:10 am