I'm currently using :s/(-[a-z].*-)([a-z])/$1\U$2/., however this just deletes the character after the 2nd - instead of converting it to an uppercase variant?
I have a CSS file and I have several entries in the form of,
ql-font-timesnewroman, ql-font-arial, ql-font-geneva, etc.
I want to convert them to ql-font-Timesnewroman, ql-font-Arial, ql-font-Geneva, etc.
I am using VSVim with VSCode, and I am not sure which version of Regex it uses (but I believe it is the Javascript variant).
If I use the PHP variant, it works fine. (https://regex101.com/r/8aZI2m/1)
But if I use the Javascript variant, it just sticks a U into the result: ql-font-Utimesnewroman.
In VSCode, it goes a step further and just inserts \U instead. (ql-font-\Utimesnewroman).
If I change the regex to look more like, :s/(-[a-z].*-)([a-z])/$1/\U$2/., it just goes ahead and erases the 2nd match instead of converting it to uppercase (ql-font-imesnewroman)
Is there any special syntax that VSVim / VSCode needs for its regex to match and replace with an uppercase correctly?
vscode v1.47 is adding support for the find/replace case modifiers like
\u, etc. See https://stackoverflow.com/a/62270300/836330In your case you could use this as the replace:
[I am not familiar with VSVIM so tell us if
s/(-[a-z].*-)([a-z])/$1\u$2/.works for you.]Older Answer:
Try this keybinding in keybindings.json, which inserts a snippet so that you can use a transform:
You select your text first and then trigger the snippet.
This will work for :
If your selection includes unrelated text, it will be unchanged UNLESS it matches the
-font-(\\w+)regex used by the snippet - which seems generally unlikely.If you have a lot of these in a file and you are uncomfortable selecting the whole file and applying this transform, then Find first with the
-font-(\w+)regex (note no need to double-escape the\win the Find widget but you must use\\win a snippet!) and Alt+Enter will select all matches and then you can trigger the snippet.