Sometimes, the smallest automation can make a big difference in your coding flow. If you frequently type . // >—maybe as part of a comment convention, markdown formatting, or a custom syntax—you can streamline your workflow by creating a hotkey in Visual Studio Code to insert it instantly.
Here’s how to do it without installing any extensions.
✅ Step 1: Create a Keybinding to Trigger the Snippet
While VS Code doesn’t allow direct keybinding to a named snippet, you can work around this by using the built-in editor.action.insertSnippet command with an inline snippet.
🔧 How to Set It Up:
- Open the Command Palette:
Ctrl+Shift+P (or Cmd+Shift+P on macOS) - Type and select:
Preferences: Open Keyboard Shortcuts (JSON) - Add the following entry to your
keybindings.jsonfile:
JSON
[
{
“key”: “ctrl+shift+q”,
“command”: “editor.action.insertSnippet”,
“args”: {
“snippet”: “. // >”
},
“when”: “editorTextFocus”
}
]
💡 You can change
"ctrl+shift+q"to any key combination that suits your workflow.
✅ Step 2: Test It
Now, whenever you’re focused in a text editor in VS Code and press Ctrl+Shift+Q, it will instantly insert:
. // >
No extensions. No fuss. Just a clean, efficient shortcut.
🧠 Bonus Tip
Want to scope this to specific file types like Markdown or Python? You can add a condition to the "when" clause, such as:
JSON
“when”: “editorTextFocus && editorLangId == ‘markdown’”