NOTE: This article is 3 years or older so its information may no longer be relevant. Read on at your own discretion! Comments for this article have automatically been locked, refer to the FAQ
for more details.
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:
After that, double clicking a PHP variable will select the entire variable as expected!
A quick disclaimer...
Although I put in a great effort into researching all the topics I cover, mistakes can happen.
If you spot something out of place, please do let me know.
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
Other posts you may like...