Select the current word in VSCode when dots or hyphens are present?

Viewed 309

How do I select the following words in VSCode: button-color or button.color ?

Ctrl-D doesn't work, it just selects the portion before/after the . or -. Ctrl-W also doesn't work even after I changed its defautl setting of closing the editor/open tab.

2 Answers

You can also change your Editor: Word Separators setting. Remove the . and - characters and it will work as you want. Just delete those characters from the list shown in the setting.

word separator setting

You can use the extension Select By.

Edit you keybindings.json

You can define or redefine the Ctrl+D with

  {
    "key": "ctrl+shift+d", // or any other combo
    "when": "editorTextFocus",
    "command": "selectby.regex",
    "args": {
      "surround": "[-.a-zA-Z0-9]+"
    }
  }
Related