template-string-converter
template-string-converter copied to clipboard
[enhancement] add key bindings for insert interpolation symbol
I could not find an adequate extension to implement this improvement. It would be great if the interpolation of the selected text worked, and a second click inside the interpolated text removed the characters.
command for keybindings: ctrl/cmd+shift+4
selected_text_or_word --> keypress --> ${cursor_in_text} --> keypress --> text
As an implementation example (inconvenient extension): https://marketplace.visualstudio.com/items?itemName=adiessl.vscode-backtix
I could not find an adequate extension to implement this improvement.
-
Install Commands extension
-
Add this to your keybindings.json:
{
"key": "alt+c",
"command": "commands.run",
"args": [
{
"command": "type",
"args": {
"text": "{"
}
},
"cursorLeft",
"cursorLeft",
{
"command": "type",
"args": {
"text": "$"
}
},
{
"command": "deleteRight",
"delay": 50
}
]
}
Note that last deleteRight is required with delay to workaround https://github.com/meganrogge/template-string-converter/issues/70 it should be removed when that issue is resolved
@truepatch is that what you wanted? The only downside of this solution is that undo stack is not clean (need to press ctrl+z several times instead of one), but this command is easy to impl here i think
@truepatch is that what you wanted? The only downside of this solution is that undo stack is not clean (need to press ctrl+z several times instead of one), but this command is easy to impl here i think
Almost, I wanted the author of the extension to improve this function, via ctrl/cmd+shift+4
// ▯ - cursor
let string = 'not select▯ed word' //press ctrl/cmd+shift+4
▼
let string = `not ${select▯ed} word` //press ctrl/cmd+shift+4
▼
let string = 'not select▯ed word'
OR
let string = '[selected words]' //press ctrl/cmd+shift+4
▼
let string = `${selected words}` //press ctrl/cmd+shift+4
▼
let string = 'selected words'