VSCode - Is there a way to customise double-click select behaviour?
If you want to achieve the same result as shared by Douglas Gaskill in his answer, but on a per language basis, that is also possible.
You simply need to specify the language, as follows (in your user settings). As the original poster wanted this for php
I'll use that example:
"[php]": {
"editor.wordSeparators": "`~!@#%^&*()=+[{]}\\|;:'\",.<>/?",
}
In this specific example, hyphens will no longer be treated as word separators (which is a pain for double-clicking any strings, terms, values, etc., that have hyphens in them), only when the editor is set to PHP
language mode.
Also, for those who are new to this...
At some stage VSCode started showing a GUI for editing Settings (I don't recall seeing that in the past), and this won't allow you to edit the editor.wordSeparators
value in the way I have indicated.
To make the changes in the way I've indicated, you'll need to open the Settings not from Code > Preferences > Settings
(on Mac, not sure how it looks on other operating systems), but instead from the Command Pallet (on Mac, that's Command-shift-P
), or View > Command Pallet
. The command is >Preferences: Open Settings (JSON)
.
You can then add in the code I've provided, or your version of it.
To get an idea of what that looks like in context of other settings, here's an example:
// Place your settings in this file to overwrite the default settings
{
"composer.executablePath": "/usr/local/bin/composer",
"terminal.integrated.shell.osx": "/usr/local/bin/powershell",
"editor.wordWrap": "on",
"extensions.autoUpdate": false
"[php]": {
"editor.wordSeparators": "`~!@#%^&*()=+[{]}\\|;:'\",.<>/?",
}
}
Since this issue has been resolved it's worth adding this answer.
You can now accomplish this in your settings by modifiying the "editor.wordSeparators"
setting.
Here is the default:
"editor.wordSeparators": "`~!@#$%^&*()-=+[{]}\\|;:'\",.<>/?"
To allow the selection of $foo
you can remove the $
from the above string.
There is nothing in the extensibility API for changing double click behavior. Its a good request though. I suggest opening an issue on Github about it. There isn't one right now and the team could use the feedback.