Visual Studio Code: Wrap Selection with Backticks

Posted Saturday, March 12, 2022 by Sri. Tagged MEMO, VISUAL STUDIO
EDITING PHASE:gathering info...

What it does When you have a selection and type one of the quote characters, the selection is wrapped in character. Also works for backticks.

Helpful in Markdown, not so much in other files. You can control when the keybind fires by using additional when clauses.

Go to Preferences->Keyboard Shortcuts then open the user keybindings.json file by clicking on the "open keyboard shortcuts (json)" icon all the way to the right on the tab bar. Add this to the array:

[
{
"key": "space",
"command": "closeParameterHints",
"when": "editorFocus && parameterHintsVisible"
},
{
"key": "shift+escape",
"command": "-closeParameterHints",
"when": "editorFocus && parameterHintsVisible"
},
{
"key": "shift+8",
"command": "editor.action.insertSnippet",
"when": "!findWidgetVisible && editorHasSelection && editorLangId==markdown",
"args": {
"snippet": "**${TM_SELECTED_TEXT}**"
}
},
{
"key": "shift+-",
"command": "editor.action.insertSnippet",
"when": "!findWidgetVisible && editorHasSelection && editorLangId==markdown",
"args": {
"snippet": "_${TM_SELECTED_TEXT}_"
}
},
{
"key": "`",
"command": "editor.action.insertSnippet",
"when": "!findWidgetVisible && editorHasSelection && editorLangId==markdown",
"args": {
"snippet": "`${TM_SELECTED_TEXT}`"
}
},
{
"key": "'",
"command": "editor.action.insertSnippet",
"when": "!findWidgetVisible && editorHasSelection && editorLangId==markdown",
"args": {
"snippet": "'${TM_SELECTED_TEXT}'"
}
},
{
"key": "shift+'",
"command": "editor.action.insertSnippet",
"when": "!findWidgetVisible && editorHasSelection && editorLangId==markdown",
"args": {
"snippet": "\"${TM_SELECTED_TEXT}\""
}
}
]