Last active
January 23, 2024 05:53
-
-
Save 3v1n0/b5f34a4e139d17c9e0d2656a9b9b7fb7 to your computer and use it in GitHub Desktop.
VSCode keybindings for alternative HJLK navigation, when using non-vim mode and support for quick panel navigation with Tab/Shift+Tab.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* VSCode keybindings for alternative HJLK navigation, when using non-vim mode | |
* and support for quick panel navigation with Tab/Shift+Tab. | |
* | |
* So basically I just tried to use everywhere in the editor these aliases: | |
* Alt+j = down | |
* Alt+k = up | |
* Alt+l = right | |
* Alt+h = left | |
* Alt+b = previous-word | |
* Alt+w = next-word | |
* Alt+u = previous-page | |
* Alt+n = next-page | |
* | |
* All these can be mixed with Ctrl or Shift, where relevant for selection | |
* or just to do the same you'd do with <AnyModifier>+<Arrow> | |
* | |
* This can be generated for newer versions using: | |
* vscode-keybindings-alt+hjkl-zation.py <path-to-default-vscode-keybindings.json> | |
* | |
* Available at: | |
* https://gist.github.com/3v1n0/f5f05005811669d81155abe0826477c8 | |
*/ | |
[ | |
/* Optional, use arrow-keys for navingating on search history entries */ | |
{ | |
"key": "up", | |
"command": "find.history.showPrevious", | |
"when": "editorFocus && findInputFocussed && findWidgetVisible" | |
}, | |
{ | |
"key": "up", | |
"command": "workbench.action.terminal.findWidget.history.showPrevious", | |
"when": "terminalFindWidgetInputFocused && terminalFindWidgetVisible" | |
}, | |
{ | |
"key": "down", | |
"command": "find.history.showNext", | |
"when": "editorFocus && findInputFocussed && findWidgetVisible" | |
}, | |
{ | |
"key": "down", | |
"command": "workbench.action.terminal.findWidget.history.showNext", | |
"when": "terminalFindWidgetInputFocused && terminalFindWidgetVisible" | |
}, | |
/* Tab and Shift+Tab support in QuickOpen panel (command palette) */ | |
{ | |
"key": "tab", | |
"command": "workbench.action.quickOpenSelectNext", | |
"when": "inQuickOpen" | |
}, | |
{ | |
"key": "tab", | |
"command": "workbench.action.quickOpenSelectNext", | |
/* Catches Quick Picker, need better see github issue */ | |
"when": "inputFocus && !editorFocus && !findInputFocussed && !findWidgetVisible" | |
}, | |
{ | |
"key": "shift+tab", | |
"command": "workbench.action.quickOpenSelectPrevious", | |
"when": "inQuickOpen" | |
}, | |
{ | |
"key": "shift+tab", | |
"command": "workbench.action.quickOpenSelectPrevious", | |
/* Catches Quick Picker, need better see github issue */ | |
"when": "inputFocus && !editorFocus && !findInputFocussed && !findWidgetVisible" | |
}, | |
/* alt+[shift]+hjkl support together with arrows support */ | |
{ | |
"key": "alt+j", | |
"command": "workbench.action.quickOpenSelectNext", | |
/* Catches Quick Picker, need better see github issue */ | |
"when": "inputFocus && !editorFocus && !findInputFocussed && !findWidgetVisible" | |
}, | |
{ | |
"key": "alt+k", | |
"command": "workbench.action.quickOpenSelectPrevious", | |
/* Catches Quick Picker, need better see github issue */ | |
"when": "inputFocus && !editorFocus && !findInputFocussed && !findWidgetVisible" | |
}, | |
{ | |
"key": "alt+h", | |
"command": "cursorLeft", | |
"when": "editorTextFocus" | |
}, | |
{ | |
"key": "alt+j", | |
"command": "cursorDown", | |
"when": "editorTextFocus" | |
}, | |
{ | |
"key": "alt+k", | |
"command": "cursorUp", | |
"when": "editorTextFocus" | |
}, | |
{ | |
"key": "alt+l", | |
"command": "cursorRight", | |
"when": "editorTextFocus" | |
}, | |
{ | |
"key": "alt+shift+h", | |
"command": "cursorLeftSelect", | |
"when": "editorTextFocus" | |
}, | |
{ | |
"command": "cursorDownSelect", | |
"key": "alt+shift+j", | |
"when": "editorTextFocus" | |
}, | |
{ | |
"key": "alt+shift+k", | |
"command": "cursorUpSelect", | |
"when": "editorTextFocus" | |
}, | |
{ | |
"key": "alt+shift+l", | |
"command": "cursorRightSelect", | |
"when": "editorTextFocus" | |
}, | |
{ | |
"key": "alt+b", | |
"command": "cursorWordStartLeft", | |
"when": "editorTextFocus" | |
}, | |
{ | |
"key": "alt+w", | |
"command": "cursorWordEndRight", | |
"when": "editorTextFocus" | |
}, | |
{ | |
"key": "alt+shift+b", | |
"command": "cursorWordStartLeftSelect", | |
"when": "editorTextFocus" | |
}, | |
{ | |
"key": "alt+shift+w", | |
"command": "cursorWordEndRightSelect", | |
"when": "editorTextFocus" | |
}, | |
{ | |
"key": "alt+u", | |
"command": "cursorPageUp", | |
"when": "editorTextFocus" | |
}, | |
{ | |
"key": "alt+n", | |
"command": "cursorPageDown", | |
"when": "editorTextFocus" | |
}, | |
{ | |
"key": "alt+shift+u", | |
"command": "cursorPageUpSelect", | |
"when": "editorTextFocus" | |
}, | |
{ | |
"key": "alt+shift+n", | |
"command": "cursorPageDownSelect", | |
"when": "editorTextFocus" | |
}, | |
{ | |
"key": "ctrl+shift+alt+k", | |
"command": "editor.action.moveLinesUpAction", | |
"when": "editorTextFocus" | |
}, | |
{ | |
"key": "ctrl+shift+alt+j", | |
"command": "editor.action.moveLinesDownAction", | |
"when": "editorTextFocus" | |
}, | |
{ | |
"key": "alt+j", | |
"command": "repl.action.historyNext", | |
"when": "editorTextFocus && inDebugRepl && onLastDebugReplLine" | |
}, | |
{ | |
"key": "alt+j", | |
"command": "settings.action.focusSettingsFile", | |
"when": "inSettingsSearch" | |
}, | |
{ | |
"key": "alt+j", | |
"command": "showNextParameterHint", | |
"when": "editorTextFocus && parameterHintsMultipleSignatures && parameterHintsVisible" | |
}, | |
{ | |
"key": "alt+j", | |
"command": "selectNextSuggestion", | |
"when": "editorTextFocus && suggestWidgetMultipleSuggestions && suggestWidgetVisible" | |
}, | |
{ | |
"key": "alt+j", | |
"command": "keybindings.editor.focusKeybindings", | |
"when": "inKeybindings && inKeybindingsSearch" | |
}, | |
{ | |
"key": "alt+j", | |
"command": "list.focusDown", | |
"when": "listFocus && !inputFocus" | |
}, | |
{ | |
"key": "alt+j", | |
"command": "search.focus.nextInputBox", | |
"when": "inputBoxFocus && searchViewletVisible" | |
}, | |
{ | |
"key": "alt+j", | |
"command": "workbench.action.interactivePlayground.arrowDown", | |
"when": "interactivePlaygroundFocus && !editorTextFocus" | |
}, | |
{ | |
"key": "alt+k", | |
"command": "repl.action.historyPrevious", | |
"when": "editorTextFocus && inDebugRepl && onFirsteDebugReplLine" | |
}, | |
{ | |
"key": "alt+k", | |
"command": "showPrevParameterHint", | |
"when": "editorTextFocus && parameterHintsMultipleSignatures && parameterHintsVisible" | |
}, | |
{ | |
"key": "alt+k", | |
"command": "selectPrevSuggestion", | |
"when": "editorTextFocus && suggestWidgetMultipleSuggestions && suggestWidgetVisible" | |
}, | |
{ | |
"key": "alt+k", | |
"command": "list.focusUp", | |
"when": "listFocus && !inputFocus" | |
}, | |
{ | |
"key": "alt+k", | |
"command": "search.action.focusSearchFromResults", | |
"when": "firstMatchFocus && searchViewletVisible" | |
}, | |
{ | |
"key": "alt+k", | |
"command": "search.focus.previousInputBox", | |
"when": "inputBoxFocus && searchViewletVisible && !searchInputBoxFocus" | |
}, | |
{ | |
"key": "alt+k", | |
"command": "workbench.action.interactivePlayground.arrowUp", | |
"when": "interactivePlaygroundFocus && !editorTextFocus" | |
}, | |
{ | |
"key": "alt+k", | |
"command": "find.history.showPrevious", | |
"when": "editorFocus && findInputFocussed && findWidgetVisible" | |
}, | |
{ | |
"key": "alt+k", | |
"command": "workbench.action.terminal.findWidget.history.showPrevious", | |
"when": "terminalFindWidgetInputFocused && terminalFindWidgetVisible" | |
}, | |
{ | |
"key": "alt+j", | |
"command": "workbench.action.quickOpenSelectNext", | |
"when": "inQuickOpen" | |
}, | |
{ | |
"key": "alt+k", | |
"command": "workbench.action.quickOpenSelectPrevious", | |
"when": "inQuickOpen" | |
}, | |
{ | |
"key": "alt+j", | |
"command": "workbench.action.compareEditor.nextChange", | |
"when": "textCompareEditorVisible && !findInputFocussed" | |
}, | |
{ | |
"key": "alt+k", | |
"command": "workbench.action.compareEditor.previousChange", | |
"when": "textCompareEditorVisible && !findInputFocussed" | |
}, | |
] |
@richellyitalo Actually I'm now using a script to generate this, so that it can be quickly updated on new revisions.
See https://gist.github.com/3v1n0/f5f05005811669d81155abe0826477c8
Thanks again!
I'll try add new commands.
Thanks again!
I'll try add new commands.
@richellyitalo, the only commands that converting won't cover are the quick-panel ones. So just need to add:
{
"key": "alt+j",
"command": "workbench.action.quickOpenSelectNext",
"when": "inQuickOpen"
},
{
"key": "alt+k",
"command": "workbench.action.quickOpenSelectPrevious",
"when": "inQuickOpen"
},
@3v1n0 nice!
Thanks buddy!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you! It's amazing!