Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.

I've recently started to use Visual Studio Code when working on PHP code. The editor is amazing right out of the box except for minor quirks. One of those quirks is to do with how it selects words on a double-click, or specifically in my case - how it selects PHP variables.
Variables in PHP are represented by a dollar sign followed by the name of the variable. The variable name is case-sensitive.

It is because of that dollar sign in front of a variable that VS Code was selecting everything after the $ when double clicking a variable and ignoring the $ itself. This was very annoying and required manually click-dragging to select a variable, which is of course not as productive.

Luckily there is an easy way to tell VS Code to do the right thing. There is a setting that controls what VS Code considers to be a word separator. There is typically a dollar sign included in this setting, so removing it from the list will make VS Code not consider $ as a separator.

Simply open Settings and add this line:
"editor.wordSeparators": "`[email protected]#%^&*()-=+[{]}\\|;:'\",.<>/?"

After that, double clicking a PHP variable will select the entire variable as expected!


Did you like this post or found it useful? Considering supporting this Blog to keep its web servers running, any amount helps! Thanks!
Have comments or feedback on what I wrote? Please share them below!
comments powered by Disqus
Other posts you may like...