Fix Sublime Text Home and End key usage on Mac OSX
I got confused with not being able to use the Home and End keys to move the cursor to the beginning and end of lines as the default functionality jumps to the beginning and end of the file. I missed this for quickly moving the cursor around, as well as selecting lines of code.
To fix this I added custom key bindings to my Sublime Text preferences.
Preferences > Key Bindings - User
Adding the following to the array;
{ "keys": ["home"], "command": "move_to", "args": {"to": "bol"} },
{ "keys": ["end"], "command": "move_to", "args": {"to": "eol"} },
{ "keys": ["shift+end"], "command": "move_to", "args": {"to": "eol", "extend": true} },
{ "keys": ["shift+home"], "command": "move_to", "args": {"to": "bol", "extend": true } }
You can now use the following combinations;
Go to beginning of line: Home
Go to end of line: End
Select from cursor position to beginning of line: ⇧ + Home
Select from the cursor position to end of line: ⇧ + End
Written by Joel Day
Related protips
14 Responses
Ok. So am I the only one using command + arrows to navigate as home/end ?
Hah, actually my laptop doesn't have home and end keys so yes I use command + arrows, however when I'm using a usb keyboard I do find them useful, perhaps it's because I'm an ex-pc user?
If you'd like to add support for using Ctrl+ to go to the beginning/end of the file, it's pretty easy! Just add these lines:
{ "keys": ["ctrl+home"], "command": "move_to", "args": {"to": "bof"} },
{ "keys": ["ctrl+end"], "command": "move_to", "args": {"to": "eof"} },
{ "keys": ["ctrl+shift+home"], "command": "move_to", "args": {"to": "bof", "extend": true} },
{ "keys": ["ctrl+shift+end"], "command": "move_to", "args": {"to": "eof", "extend": true} }
Excellent addition, I personally use CMD+SHIFT+UP and CMD+SHIFT+DOWN for this functionality.
Thank you so much! It's been driving me crazy!
My hands just couldn't get used to hitting CMD left and right. And hitting 3 keys to select a line just seems needless. Because it is. Thanks to this!
Thanks so much! Couldn't figure this out.
Thank you!!! This just made Sublime my go to editor.
Very good and like others here the default behaviour is very annoying since other editors such as IntelliJ behave with end/home being eol/bol
Thank you very much!
You saved my working day...
This is awesome! Thank you! Home and End key operation was driving me nuts specifically when using Sublime (for some reason not so much while using Terminal.. maybe because for the command line there's a different set of "rules" in the muscle memory from the UNIX/Linux world).
woooow this has made my day :') <tears of joy>
thank you! this is a must have for pc users using Macs
Great!, thank you!