Tomasz
Tomasz

Reputation: 106

Selecting text in Sublime with ctrl and shift

I've recently started using Sublime Text and there is one thing that really grinds my gear. When selecting text by arrows with CTRL and SHIFT I came across this (for me) unexpected behavior.

Let's say for example that I have lines like that:

<div>
    <p>Some text</p>
</div>

And my caret is at the end of first line right after <div>. I hold CTRL + SHIFT and press RIGHT ARROW twice (one to jump to line where <p>Some text</p> is and the second to select spaces/tabs and land right before <p>Some text</p>) but the weird thing is that also <p is getting selected.

Is there any way to configure that? I've used VS and WebStorm for a long time so this is kind of a mechanical action and this small thing in Sublime really gets me frustrated.

Upvotes: 1

Views: 173

Answers (1)

MattDMo
MattDMo

Reputation: 102842

First, open Preferences -> Key Bindings-User. If the file is completely empty, or just contains opening and closing square brackets [ ], change the contents to the following:

[
    { "keys": ["ctrl+right"], "command": "move", "args": {"by": "subwords", "forward": true} },
    { "keys": ["ctrl+shift+right"], "command": "move", "args": {"by": "subwords", "forward": true, "extend": true} }
]

If you already have some custom key bindings, add the following lines to the very beginning, on the line just after the opening bracket [:

    { "keys": ["ctrl+right"], "command": "move", "args": {"by": "subwords", "forward": true} },
    { "keys": ["ctrl+shift+right"], "command": "move", "args": {"by": "subwords", "forward": true, "extend": true} },

Make sure you save the file when you're done. This will give you the behavior you're used to.

Upvotes: 1

Related Questions