emertechie
emertechie

Reputation: 3857

Limit selection of following text in Visual Studio Code editor

Is there any way in Visual Studio Code to prevent "over-selection" when using Shift + Alt + RightArrow combo?

E.g. if I'm at the end of line 4 below and I hit that key combo, VS Code selects up until the end of bar which is never what I want and means I always have to unselect the last word:

selecting in VS Code

In JetBrain's WebStorm for example, it only selects up to start of bar which is much more useful:

enter image description here

Upvotes: 1

Views: 252

Answers (1)

emertechie
emertechie

Reputation: 3857

Ok, got it. This is controlled by the "alt+right" and "shift+alt+right" settings in the keybindings.json file.

By default they map to cursorWordEndRight and cursorWordEndRightSelect respectively. You can map them to cursorWordStartRight and cursorWordStartRightSelect by adding the following entries in your keybindings.json overrides file:

[
  { "key": "alt+right",
    "command": "cursorWordStartRight",
    "when": "editorTextFocus"
  },
  { "key": "shift+alt+right",
    "command": "cursorWordStartRightSelect",
    "when": "editorTextFocus"
  },
]

Tip: you can get to the keybindings.json file that by going to edit Keyboard Shortcuts. There's a link to edit the file at the top.

Upvotes: 1

Related Questions