I just launched a new course on ES6! Use the code WESBOS for $10 off.

Strengthen your core JavaScript skills and master all that ES6 has to offer. Start Now →

Proper go to end of line with Sublime Text

When working with wrapped lines in Sublime Text, the default go to End of line doesn’t work as expected. When you hit  cmd it will bring you to the end of the visual line, something you rarely want when working with wrapped lines:

Watch the video and read below on a quick fix to this problem.

The solution to this is to overwrite the default key bindings and set it to move to hardeol rather than just eol.

Place the following keyboard shortcuts in your key bindings file located at PreferencesKey Bindings - User. The first two control the jump to end and beginning of line while the second two do the same, but while selecting the text.

You may want to update the key bindings based on your own preference.

// Fix End of line
,{ "keys": ["super+right"], "command": "move_to", "args": {"to": "hardeol", "extend": false} }
// Fix Beginning of line
,{ "keys": ["super+left"], "command": "move_to", "args": {"to": "hardbol", "extend": false} }
// Fix end of line + select
,{ "keys": ["super+shift+right"], "command": "move_to", "args": {"to": "hardeol", "extend": true} }
// Fix beginning of line + select
,{ "keys": ["super+shift+left"], "command": "move_to", "args": {"to": "hardbol", "extend": true} }

This entry was posted in Sublime Text. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *