What I want to know
- How to set a keyboard shortcut to replace
""
with''
. - Or is there a default shortcut to replace
""
with''
?
Purpose
I use Visual Studio Code on a Mac. I often replace ""
with ''
.
For example,
const foo = "foo";
const bar = "bar";
⬇️
const foo = 'foo';
const bar = 'bar';
I usually use Visual Studio Code's replace function with a regular expression like this.
I want to register a keyboard shortcut for this operation because I do it frequently.
What I tried / Issue
I opened keybindings.json
and tried to set a keyboard shortcut in it. But I have no idea what to write.
[
{
"key": "shift+cmd+'",
"command": "actions.find" // ?????????
}
]
What should I write in there? Or is there a default shortcut to replace ""
with ''
?
Edit:
According to Jeff Brower's answer (thank you!), "args"
can be helpful for my purpose. I'm trying to change his/her code.
I wrote in keybindings.json
like this but it doesn't work:
{
"key": "shift+cmd+'",
"command": "editor.action.startFindReplaceAction",
"args": {
"query": "\"(.+)\"",
"replace": "'$1'",
"triggerSearch": true,
"isRegex": true,
"matchWholeWord": true,
"isCaseSensitive": false
}
}