Skip to content

Instantly share code, notes, and snippets.

@ashleemboyer
Created July 14, 2024 18:36
Show Gist options
  • Save ashleemboyer/5004f1d7a95f3df1b816321f6cf4249d to your computer and use it in GitHub Desktop.
Save ashleemboyer/5004f1d7a95f3df1b816321f6cf4249d to your computer and use it in GitHub Desktop.
My custom VS Code keybindings
// These override the defaults
//
// Accepted keys:
// https://code.visualstudio.com/docs/getstarted/keybindings#_accepted-keys
//
// Run multiple commands:
// https://code.visualstudio.com/docs/getstarted/keybindings#_running-multiple-commands
//
// When clause contexts
// https://code.visualstudio.com/api/references/when-clause-contexts#conditional-operators
[
// Inserts Markdown inline-code syntax and places the cursor between the backticks (`)
{
"key": "cmd+e",
"command": "runCommands",
"when": "editorLangId == markdown && editorTextFocus && !editorHasSelection",
"args": {
"commands": [
{
"command": "type",
"args": {
"text": "``"
}
},
"cursorLeft"
]
}
},
// Surrounds selected text with backticks (`) in Markdown
{
"key": "cmd+e",
"when": "editorLangId == markdown && editorHasSelection",
"command": "type",
"args": {
"text": "`"
}
},
// Inserts a 2x2 Markdown table
{
"key": "cmd+t",
"command": "type",
"when": "editorLangId == markdown && editorTextFocus && !editorHasSelection",
"args": {
"text": "| Column | Column |\n| ------ | ------ |\n| Cell | Cell |"
}
},
// Inserts Markdown hyperlink syntax and places the cursor in the link text brackets (`[]`)
{
"key": "cmd+k",
"command": "runCommands",
"when": "editorLangId == markdown && editorTextFocus && !editorHasSelection",
"args": {
"commands": [
{
"command": "type",
"args": {
"text": "[]()"
}
},
"cursorLeft",
"cursorLeft",
"cursorLeft"
]
}
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment