Editing the Cocoa application keyboard mappings
authored by Frank Lynam at 02/10/2013 13:24:50
I like coding in the TextMate text editor when working in OS X but there was always something that used to drive me absolutely mad when using it. Whenever I used the Fn+left arrow or Fn+right arrow key combination, the cursor would move to the start or the end of the current file. Being used to working in other text editors, in which these two key combinations brings you to the start or to the end of the current line, adjusting to TextMate’s interpretation was maddening, especially when it happened for the 20th time that day when working on a huge code file.
Luckily though, there is a workaround. TextMate is a Cocoa application and so it conforms to the Cocoa system keyboard mappings, which can be modified. Here’s how you change the behaviour of the Fn+left arrow to bring you to the start of the current line and the Fn+right arrow to bring you to the end of the current line.
Check to see if the ~/Library/KeyBindings folder exists. If it doesn’t, create it.
mkdir ~/Library/KeyBindings (if it doesn’t exist)
Now go to ~/Library/KeyBindings
Create a file called DefaultKeyBinding.dict
Open the file in a text editor and add the following lines.
/* home */
"UF729" = "moveToBeginningOfLine:";
/* end */
"UF72B" = "moveToEndOfLine:";
Restart TextMate or any other Cocoa application that you are using.
The Fn+left arrow and Fn+right arrow key combinations should now take you to the start or to the end of your file respectively.