Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to set up a custom key binding in Sublime Text 2 (on Mac) so that I could use my keyboard "Home" and "End" keyboard keys to go to the beginning / end of line(s) as I am used to using those keys from PC. But I am not having much luck.

As of now, I have to user "Ctrl + e" & "Ctrl + a" in Sublime to go to the beginning or end of the line.

I was trying to edit the following file.

Default (OSX).sublime-keymap --User

I am not sure what "command" to add to my code. Any help would be much appreciated.

[ { "keys": ["home"], "command": "???" }, { "keys": ["end"], "command": "???" } ]

Thanks in advance!

share|improve this question
up vote 3 down vote accepted

You can also remap home and end in OS X. Save a property list like this as ~/Library/KeyBindings/DefaultKeyBinding.dict:

{
  "\UF729" = moveToBeginningOfLine:;
  "\UF72B" = moveToEndOfLine:;
  "$\UF729" = moveToBeginningOfLineAndModifySelection:;
  "$\UF72B" = moveToEndOfLineAndModifySelection:;
}

Then quit and reopen Sublime Text or other applications to apply the changes.

See http://www.hcs.harvard.edu/~jrus/site/cocoa-text.html or http://lri.me/keybindings.html for more information.

share|improve this answer
    
Hi Lauri, Thanks for your answer. I did additional research after reading your answer and your answer does seem to be the way to go. However, I actually can't find "KeyBindings" folder on my system. If it's there, i can't find it under ~/Library/. I am using: MacBook Pro: Software OS X 10.8.3. – Vasek Oct 9 '13 at 18:40
    
@Vasek It doesn't exist by default, but you can just create it. – user495470 Oct 10 '13 at 13:28

Here is the answer to my question how to set up "Home" and "End" keyboard keybinding in Sublime Text 2 on Mac

The following code goes to Key Bindings - User file

{ "keys": ["home"], "command": "move_to", "args": {"to": "bol", "extend": false} }, { "keys": ["end"], "command": "move_to", "args": {"to": "eol", "extend": false} }

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .