Search code examples
phpvisual-studio-code

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

  • You need to remove the $ symbol from the editor.wordSeparators directive. This is the default value:

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

    You can make this language specific if you want, so it only applies to PHP.