Last Updated: April 03, 2022
·
33.71K
· dayjo

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

14 Responses
Add your response

Ok. So am I the only one using command + arrows to navigate as home/end ?

over 1 year ago ·

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?

over 1 year ago ·

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} }
over 1 year ago ·

Excellent addition, I personally use CMD+SHIFT+UP and CMD+SHIFT+DOWN for this functionality.

over 1 year ago ·

Thank you so much! It's been driving me crazy!

over 1 year ago ·

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!

over 1 year ago ·

Thanks so much! Couldn't figure this out.

over 1 year ago ·

Thank you!!! This just made Sublime my go to editor.

over 1 year ago ·

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

over 1 year ago ·

Thank you very much!
You saved my working day...

over 1 year ago ·

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).

over 1 year ago ·

woooow this has made my day :') <tears of joy>

over 1 year ago ·

thank you! this is a must have for pc users using Macs

over 1 year ago ·

Great!, thank you!

over 1 year ago ·