Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

2 Answers 2

up vote 2 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. –  ؘؘؘؘ 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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.