In Sublime Text 3 on OSX, I am able to use the keyboard shortcut "command+left/right arrow" to jump to the beginning/end of a line, as well as "command+shift+left/right arrow" to select from the point I am at to the beginning/end of the line.
Is there a way to get the same shortcut on linux or windows in the form of "ctrl+left/right arrow" and "ctrl+shift+left/right arrow" respectively?
⌘← and ⌘→ are built-in OS X shortcuts, and are not part of Sublime. However, you can mimic this behavior on Windows or Linux by overriding the default behaviors of Ctrl←/→ and CtrlShift←/→ using a custom keymap.
By default, using Ctrl←/→ moves the cursor backwards and forwards, respectively, by words, while holding down Shift allows for selection. If you want to change this, open Preferences -> Key Bindings-User
and add the following content:
{
"keys": ["ctrl+right"],
"command": "move_to", "args": {"to": "eol", "extend": false}
},
{
"keys": ["ctrl+left"],
"command": "move_to", "args": {"to": "bol", "extend": false}
},
{
"keys": ["ctrl+shift+right"],
"command": "move_to", "args": {"to": "eol", "extend": true}
},
{
"keys": ["ctrl+shift+left"],
"command": "move_to", "args": {"to": "bol", "extend": true}
}
If the file is empty when you open it, make sure you surround everything with opening and closing square brackets [ ]
. Save the file (it will automatically save in the correct place, which is the User
directory under Packages
, the directory opened when selecting Preferences -> Browse Packages...
), and your new shortcuts should work as expected. Please not that when you are working with indented text, moving to the beginning of the line with Ctrl← will move you to the beginning of the text on that line, not to the very first position on the line. If you want to do that, either hit Ctrl← again, or change bol
to hardbol
in the key definitions above.