Select only white characters in Sublime Text 3

774 views Asked by At

Currently, when you press Ctrl + Shift + Right Arrow or Ctrl + Shift + Left Arrow, Sublime Text 3 will select all spaces (all white characters) from current position until next word including this word.

Is there any way (probably yes) to modify ST3's config file or key bindings file to force it to select only spaces (white characters) only, so excluding next word? I'm really not comfortable with default behaviour.

1

There are 1 answers

1
Bohuslav Burghardt On BEST ANSWER

By default these shortcuts are defined like this:

{ "keys": ["ctrl+shift+right"], "command": "move", "args": {"by": "word_ends", "forward": true, "extend": true} },
{ "keys": ["ctrl+shift+left"], "command": "move", "args": {"by": "words", "forward": false, "extend": true} }

The important part is the by argument. What the above basically means is that the forward selection should select up to word end (whitespace + next word) and the backwards selection should select up to a word start (white space + beginning of the previous words).

Now to get the result you want you might switch the by for the forwards selection to words and for the backwards selection to word_ends. That way if you do forward selection only space up to beginning of the next word will be selected and in the case of a backwards selection the whitespace up to the end of previous word will be selected.

To customize it like this, put the following in Preferences/Keybindings - user to override the defaults.

{ "keys": ["ctrl+shift+right"], "command": "move", "args": {"by": "words", "forward": true, "extend": true} },
{ "keys": ["ctrl+shift+left"], "command": "move", "args": {"by": "word_ends", "forward": false, "extend": true} }

Try it and let me know in the comments if this works for you :)