I'm using Visual Studio Code 1.14.2, and I'm trying to change name of variables to camelCase eg.
set_nominal_wavelength to setNominalWavelength.
Regular expression: _([a-z])
Replace: \U$1\E
does not work. Any idea how to achieve it?
I'm using Visual Studio Code 1.14.2, and I'm trying to change name of variables to camelCase eg.
set_nominal_wavelength to setNominalWavelength.
Regular expression: _([a-z])
Replace: \U$1\E
does not work. Any idea how to achieve it?
In the 1.47 Insiders Build support for the replace case modifiers (\L, \l, \U, \u) has been added to vscode. And so should be in the 1.47 stable release).
So simply doing your find: _([a-z])
and replace with \u$1 (since you only want to capitalize the first letter) works nicely in the Insiders Build now.
Works in both the Find Widget and the Search Panel.
Older answer:
In October 2017 snippet variable transforms were added to vscode, see September 2017 release notes, snippet transforms.
As of then you could do this rather easily but you have to set up a simple keybinding:
{
"key": "alt+-",
"command": "editor.action.insertSnippet",
"args": {
"snippet": "${TM_SELECTED_TEXT/_([a-z])/${1:/capitalize}/g}"
}
}
_([a-z]) into your find panel,No focus changes necessary.
Unfortunately, no movement on the issue cited by Wiktor case conversions in replace as of June, 2019.
There is a workaround:
_([a-z])