feat(vscode-vim): VIM motions in VSCode

- Switch back to VIM instead of NeoVIM - we loose <ctrl+n> & <ctrl+p>
  for selection & we loose `:` & `/` integration into VSCode. But VIM
      plugin is much more faster and changing keybindings is easy.
- Made keybindings more consistent with NeoVIM
This commit is contained in:
Pratik Tripathy
2024-12-24 18:42:16 +05:30
parent 3d9f4769f7
commit 1ceab0a908
3 changed files with 275 additions and 16 deletions

View File

@@ -11,15 +11,18 @@
},
{
"key": "ctrl+shift+alt+right",
"command": "editor.emmet.action.nextEditPoint"
"command": "editor.emmet.action.nextEditPoint",
"when": "editorTextFocus"
},
{
"key": "ctrl+shift+alt+t",
"command": "editor.emmet.action.matchTag"
"command": "editor.emmet.action.matchTag",
"when": "editorTextFocus"
},
{
"key": "ctrl+shift+alt+p",
"command": "editor.emmet.action.wrapWithAbbreviation"
"command": "editor.emmet.action.wrapWithAbbreviation",
"when": "editorTextFocus"
},
{
"key": "alt+q",
@@ -48,7 +51,8 @@
},
{
"key": "ctrl+shift+j",
"command": "editor.action.joinLines"
"command": "editor.action.joinLines",
"when": "editorTextFocus"
},
{
"key": "ctrl+shift+j",
@@ -62,5 +66,255 @@
{
"key": "shift+escape",
"command": "workbench.action.toggleSidebarVisibility"
},
// vim.keybindings
// Navigation
{
"key": "ctrl+h",
"command": "workbench.action.navigateLeft"
},
{
"key": "ctrl+l",
"command": "workbench.action.navigateRight"
},
{
"key": "ctrl+k",
"command": "workbench.action.navigateUp"
},
{
"key": "ctrl+j",
"command": "workbench.action.navigateDown"
},
{
"key": "space b l",
"command": "workbench.action.showAllEditors",
"when": "vim.mode == 'Normal' && editorTextFocus"
},
{
"key": "space b x",
"command": "workbench.action.closeActiveEditor",
"when": "vim.mode == 'Normal' && editorTextFocus"
},
{
"key": "] b",
"command": "workbench.action.nextEditorInGroup",
"when": "(vim.mode == 'Normal' || vim.mode == 'Visual') && editorTextFocus"
},
{
"key": "[ b",
"command": "workbench.action.previousEditorInGroup",
"when": "(vim.mode == 'Normal' || vim.mode == 'Visual') && editorTextFocus"
},
{
"key": "space e",
"command": "runCommands",
"args": {
"commands": [
"workbench.action.toggleSidebarVisibility",
"workbench.files.action.focusFilesExplorer"
]
},
"when": "vim.mode == 'Normal'"
},
{
"key": "space e",
"command": "runCommands",
"args": {
"commands": [
"workbench.action.toggleSidebarVisibility",
"workbench.action.focusActiveEditorGroup"
]
},
"when": "sideBarFocus && !inputFocus"
},
{
"key": "space e",
"command": "workbench.action.toggleSidebarVisibility",
"when": "vim.mode == 'Normal' && foldersViewVisible"
},
// Editor
{
"key": "shift shift",
"command": "workbench.action.quickOpen",
"when": "vim.mode == 'Normal'"
},
{
"key": "space g g",
"command": "runCommands",
"when": "vim.mode == 'Normal'",
"args": {
"commands": ["workbench.view.scm", "workbench.scm.focus"]
}
},
{
"key": "ctrl+alt+f",
"command": "workbench.action.findInFiles",
"when": "vim.mode == 'Normal'"
},
{
"key": "space p",
"command": "editor.action.clipboardPasteAction",
"when": "vim.mode == 'Normal' && editorTextFocus"
},
{
"key": "space y",
"command": "editor.action.clipboardCopyAction",
"when": "vim.mode == 'Normal' && editorTextFocus"
},
{
"key": "space x o",
"command": "workbench.action.closeOtherEditors",
"when": "vim.mode == 'Normal' && editorTextFocus"
},
{
"key": "ctrl+n",
"command": "-workbench.action.files.newUntitledFile"
},
// File Explorer
{
"key": "r",
"command": "renameFile",
"when": "filesExplorerFocus && foldersViewVisible && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
},
{
"key": "c",
"command": "filesExplorer.copy",
"when": "filesExplorerFocus && foldersViewVisible && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
},
{
"key": "p",
"command": "filesExplorer.paste",
"when": "filesExplorerFocus && foldersViewVisible && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
},
{
"key": "x",
"command": "filesExplorer.cut",
"when": "filesExplorerFocus && foldersViewVisible && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
},
{
"key": "d",
"command": "deleteFile",
"when": "filesExplorerFocus && foldersViewVisible && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
},
{
"key": "n",
"command": "explorer.newFile",
"when": "filesExplorerFocus && foldersViewVisible && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
},
{
"key": "shift+n",
"command": "explorer.newFolder",
"when": "filesExplorerFocus && foldersViewVisible && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
},
{
"key": "s",
"command": "explorer.openToSide",
"when": "filesExplorerFocus && foldersViewVisible && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
},
{
"key": "shift+s",
"command": "runCommands",
"when": "filesExplorerFocus && foldersViewVisible && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus",
"args": {
"commands": [
"workbench.action.splitEditorDown",
"explorer.openAndPassFocus",
"workbench.action.closeOtherEditors"
]
}
},
{
"key": "enter",
"command": "explorer.openAndPassFocus",
"when": "filesExplorerFocus && foldersViewVisible && !explorerResourceIsRoot && !explorerResourceIsFolder && !inputFocus"
},
{
"key": "enter",
"command": "list.toggleExpand",
"when": "filesExplorerFocus && foldersViewVisible && !explorerResourceIsRoot && explorerResourceIsFolder && !inputFocus"
},
// Coding
{
"key": "shift+k",
"command": "editor.action.showHover",
"when": "vim.mode == 'Normal' && editorTextFocus"
},
{
"key": "shift+j",
"command": "editor.action.moveLinesDownAction",
"when": "vim.mode == 'VisualLine' && editorTextFocus"
},
{
"key": "shift+k",
"command": "editor.action.moveLinesUpAction",
"when": "vim.mode == 'VisualLine' && editorTextFocus"
},
{
"key": "space c i",
"command": "editor.action.goToImplementation",
"when": "vim.mode == 'Normal' && editorTextFocus"
},
{
"key": "space c r",
"command": "editor.action.goToReferences",
"when": "vim.mode == 'Normal' && editorTextFocus"
},
{
"key": "space c s",
"command": "workbench.action.gotoSymbol",
"when": "vim.mode == 'Normal' && editorTextFocus"
},
{
"key": "space c w",
"command": "workbench.action.showAllSymbols",
"when": "vim.mode == 'Normal' && editorTextFocus"
},
{
"key": "space o",
"command": "workbench.action.gotoSymbol",
"when": "vim.mode == 'Normal' && editorTextFocus"
},
{
"key": "space d w",
"command": "workbench.actions.view.problems",
"when": "vim.mode == 'Normal' && editorTextFocus"
},
// Test commands
{
"key": "space t t",
"command": "testing.runAtCursor",
"when": "vim.mode == 'Normal' && editorTextFocus"
},
{
"key": "space t f",
"command": "testing.runCurrentFile",
"when": "vim.mode == 'Normal' && editorTextFocus"
},
{
"key": "space t w",
"command": "testing.runAll",
"when": "vim.mode == 'Normal' && editorTextFocus"
},
{
"key": "space t x",
"command": "testing.cancelRun",
"when": "vim.mode == 'Normal' && editorTextFocus"
}
// Make the following work: ctrl+n & ctrl+p for navigation through dropdown
// {
// "key": "ctrl+n",
// "command": "selectNextSuggestion",
// "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
// },
// {
// "key": "ctrl+p",
// "command": "selectPrevSuggestion",
// "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
// },
]

View File

@@ -8,7 +8,7 @@
"extensions.ignoreRecommendations": true,
// Editor
"editor.fontSize": 18,
"editor.fontSize": 15,
"editor.cursorWidth": 3,
"editor.minimap.enabled": false,
"editor.wordWrap": "on",
@@ -35,12 +35,10 @@
"editor.fontLigatures": true,
"terminal.integrated.fontFamily": "FiraCode Nerd Font Mono",
"terminal.integrated.fontSize": 15,
// Workbench - Everything that surrounds the editor
"workbench.colorTheme": "GitHub Dark Dimmed",
"workbench.iconTheme": "material-icon-theme",
"workbench.startupEditor": "newUntitledFile",
"workbench.sideBar.location": "right",
"workbench.colorTheme": "GitHub Dark Default",
"workbench.colorCustomizations": {
"tab.activeBackground": "#07f7af3f",
"tab.activeBorder": "#ffffff",
@@ -58,20 +56,21 @@
"projectManager.git.baseFolders": [".git"],
// VIM & NeoVIM
"keyboard.dispatch": "keyCode", // For Linux, <Caps> -> <Esc> binding to work
"extensions.experimental.affinity": {
"asvetliakov.vscode-neovim": 1,
"vscodevim.vim": 1
},
"keyboard.dispatch": "keyCode", // For Linux, <Caps> -> <Esc> binding to work
"vim.leader": " ",
"vim.easymotion": true,
"vim.smartRelativeLine": true,
"vim.showMarksInGutter": true,
"vim.replaceWithRegister": true,
"vim.highlightedyank.enable": true,
"vim.cursorStylePerMode.normal": "block",
"vim.cursorStylePerMode.replace": "block",
"vim.cursorStylePerMode.visual": "block",
"vim.cursorStylePerMode.replace": "block",
"vim.cursorStylePerMode.visualblock": "block",
"vim.cursorStylePerMode.visualline": "block",
"vim.smartRelativeLine": true,
"vim.easymotion": true,
// Debugging
"debug.toolBarLocation": "docked",
@@ -111,6 +110,12 @@
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true
},
"[shellscript]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
},
"[dockerfile]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
},
// Better Comments
"better-comments.tags": [
@@ -291,6 +296,6 @@
"sql-formatter.dialect": "pl/sql",
// Windsurf
"windsurf.enableSupercomplete": false,
"windsurf.enableAutocomplete": false
"windsurf.enableSupercomplete": true,
"windsurf.enableAutocomplete": true
}