2

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!

2 Answers 2

5

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.

2
  • 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, 2013 at 18:40
  • 1
    @Vasek It doesn't exist by default, but you can just create it.
    – Lri
    Oct 10, 2013 at 13:28
0

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} }

You must log in to answer this question.

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