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.
vscode_sel1.png


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.
vscode_sel3.png




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


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


-i

A quick disclaimer...

Although I put in a great effort into researching all the topics I cover, mistakes can happen. Use of any information from my blog posts should be at own risk and I do not hold any liability towards any information misuse or damages caused by following any of my posts.

All content and opinions expressed on this Blog are my own and do not represent the opinions of my employer (Oracle). Use of any information contained in this blog post/article is subject to this disclaimer.
Hi! You can search my blog here ⤵
NOTE: (2022) This Blog is no longer maintained and I will not be answering any emails or comments.

I am now focusing on Atari Gamer.