22

Is there a way to customize (i.e., in settings.json) the set of characters used to delimit words and tokens in Visual Studio Code? I'm referring to the set of characters used to control the behavior of actions like Alt+Left, Alt+Right, or double-clicks when navigating text.

Sublime Text supports a "word_separators" option for settings files that take a set of characters like “./\()"’-:,.;<>~!@#$%^&*|+=[]{}~?”. Does Code support a similar feature?

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
Michael Zalla
  • 804
  • 1
  • 5
  • 14
  • As far as I know word separators are managed per language in the language definition file. Take a look for example into your code installation folder in resources\app\plugins\vs.language.csharp\csharpDef.js there you will find the line that defines word separators for this language: "wordDefinition: /(-?\d*\.\d\w*)|([^\`\~\!\#\$\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g" - You could edit the definition for your language. But I'm not sure about the side effects. I think the separators are well defined by MS. Maybe you encountered a bug? What do you want to change exactly? – Wosi Jul 28 '15 at 13:48

2 Answers2

40

As of the February update, v0.10.10 (February 2016), word navigation and word separators has now been added! As of today you can view the update announcement here under "Word navigation and word separators", but after the next release the url will probably change to this... I make this assumption based on previous releases.

Your settings file(s) now contain a section for editing word navigation and word separators

// Characters that will be used as word separators when doing word related navigations or operations
"editor.wordSeparators": "`~!@#$%^&*()-=+[{]}\\|;:'\",.<>/?",
Prancer
  • 3,336
  • 2
  • 32
  • 38
10

To enable double click selecting the "$" symbol (for example) along with other text as well, you need to remove "$" symbol from delimiters.

Settings -> Preferences -> search "editor.wordSeparators" -> remove $ symbol Vs Code delimiters

Adding this answer, because similar googling pointed me here. Hope comes useful to someone.

Remark: This was working till 2020 I guess, than Microsoft changed something in Vscode and now you need to specify "sepeterators-per-language":

  1. Open settings.json (ctrl+p settings.json)
  2. add following line at the end of the file:
"[powershell]": {
            "editor.wordSeparators": "`~!@#%^&*()=+[{]}\\|;:'\",.<>/?",
        }

Just specify your language in [ ] and remove symbol you want to select with double click as well.

Near Future
  • 175
  • 1
  • 8