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

Skip down to comments...
Hope you found this post useful...

...so please read on! I love writing articles that provide beneficial information, tips and examples to my readers. All information on my blog is provided free of charge and I encourage you to share it as you wish. There is a small favour I ask in return however - engage in comments below, provide feedback, and if you see mistakes let me know.

If you want to show additional support and help me pay for web hosting and domain name registration, donations, no matter how small, are always welcome!

Use of any information contained in this blog post/article is subject to this disclaimer.
 
comments powered by Disqus
Other posts you may like...