Skip to content

Instantly share code, notes, and snippets.

@roalcantara
Created August 19, 2019 23:47
Show Gist options
  • Save roalcantara/562ae7879e0c38a71b19e088d5f81501 to your computer and use it in GitHub Desktop.
Save roalcantara/562ae7879e0c38a71b19e088d5f81501 to your computer and use it in GitHub Desktop.
VSCode: Surround selection with double or single quotation marks

VSCode: Surround selection with double or single quotation marks

Directions

  1. In VS Code, hold Command + Shift + P (for mac) or Ctrl + Shift + P
  2. Type Preferences: Open Keyboard Shortcuts (JSON) and press [Enter]
  3. On keybindings.json, paste and adapt if so the vscode_keybindings_surroundings.json's content
  4. Here's my current full version (with other previously existing keybindings):
// Place your key bindings in this file to override the defaults
[
  {
    "key": "shift+alt+p",
    "command": "editor.action.formatDocument",
    "when": "editorTextFocus"
  },
  {
    "key": "shift+alt+p",
    "command": "editor.action.formatSelection",
    "when": "editorHasSelection"
  },
  {
    "key": "'",
    "command": "editor.action.insertSnippet",
    "when": "editorHasSelection || editorHasMultipleSelections",
    "args": {
      "snippet": "'${TM_SELECTED_TEXT}"
    }
  },
  {
    "key": "shift+'",
    "command": "editor.action.insertSnippet",
    "when": "editorHasSelection || editorHasMultipleSelections",
    "args": {
      "snippet": "\"${TM_SELECTED_TEXT}"
    }
  }
]
[
{
"key": "'",
"command": "editor.action.insertSnippet",
"when": "editorHasSelection || editorHasMultipleSelections",
"args": {
"snippet": "'${TM_SELECTED_TEXT}"
}
},
{
"key": "shift+'",
"command": "editor.action.insertSnippet",
"when": "editorHasSelection || editorHasMultipleSelections",
"args": {
"snippet": "\"${TM_SELECTED_TEXT}"
}
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment