Preserve $ When Copying PHP Variables
By default you can't copy the complete string as it leaves out the $ for example $table_name copied becomes just table_name and drops the $.
This happens because Visual Studio Code treats the $ symbol as a word separator by default, meaning it doesn’t get included when selecting or copying variable names in PHP.
How to Fix It
You can adjust VS Code’s settings to ensure $ is included when selecting and copying variables:
- Modify settings.json:
- Open VS Code.
- Press Ctrl + Shift + P (or Cmd + Shift + P on Mac) and search for Preferences: Open User Settings (JSON).
- Add the following configuration at the end
"[php]": {
"editor.wordSeparators": "`~!@#%^&*()-=+[{]}\\|;:'\",.<>/?"
}
Topic last reviewed: 10/05/25