'How to select the whole variable name including $ in Visual Studio Code in PHP?

I am using the latest version of Visual Studio Code and I am using the PHP programming language. I am selecting a variable but it only selects the variable name, not the $ symbol.

By default it selects like this:

Selection of variable name without dollar sign

But I want it like this:

Selection of variable name with dollar sign

Is there any setting that enables this behavior?

Any information on this would be greatly appreciated. Thanks!



Solution 1:[1]

The best way is to edit the VsCode settings.json and specify it for the PHP language. You can open it typing VsCode command:

Preferences: open settings (JSON)

And specify inside the "editor.wordSeparators" setting for your language removing the '$' symbol:

"[php]": {
  "editor.wordSeparators": "`~!@#%^&*()-=+[{]}\\|;:'\",.<>/?"
}

Solution 2:[2]

you can in simple

file > preferences > Sittings

Extensions -> PHP

enter image description here

in file sittings.json

{
   "editor.wordSeparators": "`~!@#%^&*()-=+[{]}\\|;:'\",.<>/?"
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 David Folch Agulles
Solution 2 Waad Mawlood