Skip to content

Instantly share code, notes, and snippets.

@luckygoswami
Last active November 15, 2024 18:12
Show Gist options
  • Select an option

  • Save luckygoswami/96aa910dc0d4eefbdd7ab7bafab22157 to your computer and use it in GitHub Desktop.

Select an option

Save luckygoswami/96aa910dc0d4eefbdd7ab7bafab22157 to your computer and use it in GitHub Desktop.
vs code custom keyboard shortcuts
[
{
"key": "ctrl+alt+s",
"command": "code-runner.run"
},
{
"key": "ctrl+alt+n",
"command": "-code-runner.run"
},
{
"key": "ctrl+alt+space",
"command": "code-runner.stop"
},
{
"key": "ctrl+alt+m",
"command": "-code-runner.stop"
},
{
"key": "ctrl+alt+d",
"command": "editor.action.addSelectionToPreviousFindMatch"
},
{
"key": "shift+backspace",
"command": "editor.action.deleteLines",
"when": "textInputFocus && !editorReadonly"
},
{
"key": "ctrl+shift+k",
"command": "-editor.action.deleteLines",
"when": "textInputFocus && !editorReadonly"
},
{
"key": "shift+enter",
"command": "-python.execSelectionInTerminal",
"when": "editorTextFocus && !findInputFocussed && !jupyter.ownsSelection && !notebookEditorFocused && !replaceInputFocussed && editorLangId == 'python'"
},
{
"key": "ctrl+shift+space",
"command": "closeParameterHints",
"when": "editorFocus && parameterHintsVisible"
},
{
"key": "ctrl+alt+k",
"command": "terminal.focus"
},
{
"key": "ctrl+shift+k",
"command": "workbench.action.focusActiveEditorGroup"
},
{
"key": "shift+alt+a",
"command": "editor.action.sortLinesAscending"
},
{
"key": "shift+alt+a",
"command": "-editor.action.blockComment",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+alt+k",
"command": "-code-runner.runCustomCommand"
},
{
"key": "ctrl+shift+alt+k",
"command": "bookmarks.toggle",
"when": "editorTextFocus"
},
{
"key": "ctrl+alt+k",
"command": "-bookmarks.toggle",
"when": "editorTextFocus"
}
]
@luckygoswami
Copy link
Author

luckygoswami commented Oct 3, 2024

VS Code Custom Keybindings

This Gist contains my personalized VS Code keybindings configuration (keybindings.json). These keybindings optimize productivity by tailoring shortcuts for specific tasks, improving workflow and minimizing conflicts.


Installation

To use these keybindings in your VS Code environment:

  1. Open VS Code.
  2. Navigate to File > Preferences > Keyboard Shortcuts.
  3. Click the Open Keyboard Shortcuts (JSON) icon in the top-right corner.
  4. Replace the contents of your keybindings.json with the file provided in this Gist.

Key Shortcuts

Key Combination Command Description
Ctrl + Alt + S code-runner.run Run the code using Code Runner.
Ctrl + Alt + N -code-runner.run Removed the shortcut for running Code Runner.
Ctrl + Alt + Space code-runner.stop Stop code execution in Code Runner.
Ctrl + Alt + M -code-runner.stop Removed the shortcut for stopping Code Runner.
Ctrl + Alt + D editor.action.addSelectionToPreviousFindMatch Add selection to the previous find match.
Shift + Backspace editor.action.deleteLines Delete the current line.
Ctrl + Shift + K -editor.action.deleteLines Removed the default line deletion shortcut.
Shift + Enter -python.execSelectionInTerminal Removed Python-specific shortcut for execution.
Ctrl + Shift + Space closeParameterHints Close parameter hints for function signatures.
Ctrl + Alt + K terminal.focus Focus on the integrated terminal.
Ctrl + Shift + K workbench.action.focusActiveEditorGroup Focus on the active editor group.
Shift + Alt + A editor.action.sortLinesAscending Sort selected lines in ascending order.
Shift + Alt + A -editor.action.blockComment Removed the block comment shortcut.
Ctrl + Alt + K -code-runner.runCustomCommand Removed custom Code Runner command shortcut.
Ctrl + Shift + Alt + K bookmarks.toggle Toggle bookmarks.
Ctrl + Alt + K -bookmarks.toggle Removed the default bookmark toggle shortcut.

Additional Notes

Code Runner Integration

  • Ctrl + Alt + S: The primary shortcut to run code using Code Runner.
  • Ctrl + Alt + Space: Stops the execution of Code Runner.
  • Removed redundant Code Runner shortcuts (Ctrl + Alt + N, Ctrl + Alt + M, Ctrl + Alt + K).

Editor Shortcuts

  • Replaced Shift + Alt + A for block commenting with sorting lines in ascending order.
  • Focus management shortcuts for terminal and editor navigation have been customized (Ctrl + Alt + K, Ctrl + Shift + K).

Removed Shortcuts

  • Removed Python-specific shortcuts like Shift + Enter to prevent conflicts with other extensions.
  • Removed unused or redundant commands, such as custom Code Runner commands and bookmark toggling.

Feel free to fork this Gist and adjust these keybindings to match your preferences!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment