vscode vim config

发布时间 2023-09-24 00:05:25作者: 虎虎生威啊

keybindings.json

// Place your key bindings in this file to override the defaultsauto[]
[
  // terminal================= 
  // 切换到terminal终端
  {
    "key": "ctrl+,",
    "command": "workbench.action.terminal.toggleTerminal",
    "when": "terminal.active"
  },
  // 打开一个新的terminal
  {
    "key": "ctrl+shift+,",
    "command": "workbench.action.terminal.new",
    "when": "terminalProcessSupported || terminalWebExtensionContributedProfile"
  },
  {
    "key": "alt+j",
    "command": "workbench.action.terminal.focusNext",
    "when": "terminalFocus"
  },
  {
    "key": "alt+k",
    "command": "workbench.action.terminal.focusPrevious",
    "when": "terminalFocus"
  },


  // 切换到文件浏览器,可以在任何位置
  // {
  //   "key": "ctrl+;",
  //   "command": "workbench.view.explorer",
  //   "when": "viewContainer.workbench.view.explorer.enabled"
  // },

  // 切换到代码编辑区,不论在任何位置
  {
    "key": "ctrl+'",
    "command": "workbench.action.focusFirstEditorGroup"
  },
  // 在file tree 和editor区域切换 
  {
    "command": "workbench.action.focusFirstEditorGroup",
    "key": "ctrl+;",
  },
  {
    "command": "workbench.files.action.focusFilesExplorer",
    "key": "ctrl+;",
    "when": "editorTextFocus"
  },
  {
    "key": "ctrl+shift+j",
    "command": "workbench.action.togglePanel"
  },
  // 在文件夹资源管理器中新建一个文件
  {
    "key": "a",
    "command": "explorer.newFile",
    "when": "filesExplorerFocus && !inputFocus"
  },
  // 在文件资源管理器里面创建一个文件夹
  {
    "key": "shift+a",
    "command": "explorer.newFolder",
    "when": "filesExplorerFocus && !inputFocus"
  },
  // 在文件资源管理器里面重应名当前文件或文件夹
  {
    "key": "r",
    "command": "renameFile",
    "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
  },
  // 在文件资源管理器中删除文件
  {
    "key": "d",
    "command": "deleteFile",
    "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceReadonly && !inputFocus"
  },

  // 放大editor区域
  {
    "key": "ctrl+m",
    "command": "workbench.action.maximizeEditor"
  },

  // 使用code runner运行代码
  {
    "key": "ctrl+r",
    "command": "code-runner.run"
  },
  {
    "key": "y",
    "command": "filesExplorer.copy",
    "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceIsRoot && !inputFocus"
  },
  {
    "key": "p",
    "command": "filesExplorer.paste",
    "when": "explorerViewletVisible && filesExplorerFocus && !explorerResourceReadonly && !inputFocus"
  },
  {
    "key": "ctrl+s",
    "command": "workbench.action.files.save"
  },
  {
    "key": "ctrl+/",
    "command": "-workbench.action.terminal.sendSequence",
    "when": "terminalFocus"
  },
  {
    "key": "ctrl+/",
    "command": "editor.action.commentLine",
    "when": "editorTextFocus && !editorReadonly"
  },
  {
    "key": "cmd+/",
    "command": "-editor.action.commentLine",
    "when": "editorTextFocus && !editorReadonly"
  }
]

settings.json

{
  // 开启markdown的代码片提示
  "[markdown]": {
    "editor.quickSuggestions": {
      "comments": "on",
      "strings": "on",
      "other": "on"
    }
  },
  // ---------------------
  "code-runner.runInTerminal": true,
  "code-runner.executorMap": {
    "javascript": "node",
    "java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
    "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
    "zig": "zig run",
    "cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
    "objective-c": "cd $dir && gcc -framework Cocoa $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
    "php": "php",
    "python": "python -u",
    "perl": "perl",
    "perl6": "perl6",
    "ruby": "ruby",
    "go": "go run",
    "lua": "lua",
    "groovy": "groovy",
    "powershell": "powershell -ExecutionPolicy ByPass -File",
    "bat": "cmd /c",
    "shellscript": "bash",
    "fsharp": "fsi",
    "csharp": "scriptcs",
    "vbscript": "cscript //Nologo",
    "typescript": "ts-node",
    "coffeescript": "coffee",
    "scala": "scala",
    "swift": "swift",
    "julia": "julia",
    "crystal": "crystal",
    "ocaml": "ocaml",
    "r": "Rscript",
    "applescript": "osascript",
    "clojure": "lein exec",
    "haxe": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt",
    "rust": "cd $dir && rustc $fileName && $dir$fileNameWithoutExt",
    "racket": "racket",
    "scheme": "csi -script",
    "ahk": "autohotkey",
    "autoit": "autoit3",
    "dart": "dart",
    "pascal": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
    "d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt",
    "haskell": "runghc",
    "nim": "nim compile --verbosity:0 --hints:off --run",
    "lisp": "sbcl --script",
    "kit": "kitc --run",
    "v": "v run",
    "sass": "sass --style expanded",
    "scss": "scss --style expanded",
    "less": "cd $dir && lessc $fileName $fileNameWithoutExt.css",
    "FortranFreeForm": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
    "fortran-modern": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
    "fortran_fixed-form": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
    "fortran": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
    "sml": "cd $dir && sml $fileName"
  },
  //-------------------------------------------------
  // yapf
  // "python.formatting.provider": "yapf",
  "python.formatting.yapfArgs": [
    "--style",
    "{column_limit: 150}"
  ],
  // autopep8
  "python.formatting.provider": "autopep8",
  "python.formatting.autopep8Args": [
    "--max-line-length=150"
  ],
  // black
  // "python.formatting.provider": "black",
  "python.formatting.blackArgs": [
    "--line-length",
    "150"
  ],
  //--------------------------------------------------
  "[vue]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[typescript]": {
    "editor.defaultFormatter": "vscode.typescript-language-features"
  },
  "editor.lineNumbers": "on",
  "[javascript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },

  // ==================vim config========================================
  "vim.leader": "<space>",
  "vim.useSystemClipboard": true,
  "vim.hlsearch": true,
  "vim.highlightedyank.enable": true,
  "vim.foldfix": true,
  "vim.easymotion": true,
  "vim.incsearch": true,
  "vim.useCtrlKeys": true,
  "vim.surround": true,
  "vim.sneak": true,
  "vim.sneakUseIgnorecaseAndSmartcase": true,
  // 自动切换输入法的配置 im-select,当切换到vim的普通模式下,会自动切换abc输入法
  "vim.autoSwitchInputMethod.enable": true,
  "vim.autoSwitchInputMethod.defaultIM": "com.apple.keylayout.ABC",
  "vim.autoSwitchInputMethod.obtainIMCmd": "/opt/homebrew/bin/im-select",
  "vim.autoSwitchInputMethod.switchIMCmd": "/opt/homebrew/bin/im-select {im}",

  //----------------------------------------
  "vim.normalModeKeyBindingsNonRecursive": [
    // Go to start or end of line---------------------------
    {
      "before": [
        "H"
      ],
      "after": [
        "^"
      ]
    },
    {
      "before": [
        "L"
      ],
      "after": [
        "$"
      ]
    },
    // ----------------------------------------------------
    // Jump to change
    {
      "before": [
        "[",
        "c"
      ],
      "commands": [
        "workbench.action.editor.previousChange"
      ]
    },
    {
      "before": [
        "]",
        "c"
      ],
      "commands": [
        "workbench.action.editor.nextChange"
      ]
    },
    // Code actions
    {
      "before": [
        "<leader>",
        "s",
        "a"
      ],
      "commands": [
        "editor.action.sourceAction"
      ]
    },
    {
      "before": [
        "<space>",
        "r",
        "r"
      ],
      "commands": [
        // "extension.runScript"
        // "autojspro.run"
        "code-runner.run"
      ]
    },
    // ----------------------------
    // 重用名变量
    {
      "before": [
        "<leader>",
        "r",
        "n"
      ],
      "commands": [
        "editor.action.rename"
      ]
    },
    // go===================================================
    // go to  References
    {
      "before": [
        "g",
        "r"
      ],
      "commands": [
        "editor.action.goToReferences"
      ]
    },
    {
      "before": [
        "g",
        "e"
      ],
      "commands": [
        "editor.action.marker.next"
      ],
      "when": "editorFocus"
    },
    {
      "before": [
        "g",
        "E"
      ],
      "commands": [
        "editor.action.marker.prev"
      ],
      "when": "editorFocus"
    },
    // ===================================================
    // new===================================================
    // 新建文件夹,在编辑器的区域
    {
      "before": ["<Leader>", "n", "d"],
      "commands": ["explorer.newFolder"]
    },
    // 新建文件,新建文件的位置取决于,文件资源管理器所在的位置
    {
      "before": ["<Leader>", "n", "f"],
      "commands": ["explorer.newFile"]
    },
    // =====================================================
    // open========================================================

    // 打开文件资源管理器,光标会聚焦到文件资源管理器的窗口
    {
      "before": ["<leader>",  "e"],
      "commands": ["workbench.view.explorer"]
    },

    // 进入到terminal
    {
      "before": [
        "<leader>",
        "t",
        "t"
      ],
      "commands": [
        "workbench.action.terminal.toggleTerminal"
      ]
    },

    // 新建一个terminal终端
    {
      "before": [
        "<leader>",
        "t",
        "n"
      ],
      "commands": [
        "workbench.action.terminal.new"
      ]
    },

    // 隐藏和打开terminal
    {
      "before": [
        "<leader>",
        "t",
        "h"
      ],
      "commands": [
        "workbench.action.togglePanel"
      ]
    },

    // ================================================


    // ===============================================
    // 移动==============================================================================
    // 左右移动标签页------------------------------------------------
    {
      "before": [
        "<leader>",
        "h"
      ],
      "commands": [
        "workbench.action.navigateLeft"
      ]
    },
    {
      "before": [
        "<leader>",
        "l"
      ],
      "commands": [
        "workbench.action.navigateRight"
      ]
    },
    // 移动下一个编辑器标签
    {
      "before": [
        "J"
      ],
      // "commands": ["workbench.action.nextEditor"]
      "commands": [
        ":bnext"
      ]
    },
    // 移动到上一个编辑器标签
    {
      "before": [
        "K"
      ],
      // "commands": ["workbench.action.previousEditor"]
      "commands": [
        ":bprevious"
      ]
    },
    // splits 
    {
      "before": [
        "<space>",
        "v"
      ],
      "commands": [
        ":vsplit"
      ]
    },
    {
      "before": [
        "<space>",
        "s"
      ],
      "commands": [
        ":split"
      ]
    },
    // panes
    {
      "before": [
        "<space>",
        "h"
      ],
      "commands": [
        "workbench.action.focusLeftGroup"
      ]
    },
    {
      "before": [
        "<space>",
        "j"
      ],
      "commands": [
        "workbench.action.focusBelowGroup"
      ]
    },
    {
      "before": [
        "<space>",
        "k"
      ],
      "commands": [
        "workbench.action.focusAboveGroup"
      ]
    },
    {
      "before": [
        "<space>",
        "l"
      ],
      "commands": [
        "workbench.action.focusRightGroup"
      ]
    },
    // 左右移动标签页---------------------------------------------------------------
    {
      "before": ["<space>", "m"],
      "commands": ["workbench.action.maximizeEditor"]
    },
    
    {
      "before": [
        "g",
        "b"
      ],
      "commands": [
        "workbench.action.navigateBack"
      ],
      "when": "canNavigateBack"
    },


    {
      "before": [
        "<space>",
        "q",
        "f"
      ],
      "commands": [
        "editor.action.quickFix"
      ]
    },
    {
      "before": [
        "<space>",
        "c",
        "p"
      ],
      "commands": [
        "copyFilePath"
      ],
      "when": "!editorFocus"
    },
    // NICE TO HAVE
    // 保存当前文件---------------------------------------------------------------
    // {
    //   "before": ["<space>", "s"],
    //   "commands": ["workbench.action.files.save"]
    // },
    {
      "before": [
        "leader",
        "w"
      ],
      "commands": [
        ":w!"
      ]
    },

    {
      "before": [
        "leader",
        "q"
      ],
      "commands": [
        ":q!"
      ]
    },

    // =================================================================
    // {
    //   "before": [
    //     "leader",
    //     "x"
    //   ],
    //   "commands": [
    //     ":x!"
    //   ]
    // },
    // workbench.action.closeActiveEditor
    {
      "before": ["<space>", "c", "c"],
      "commands": ["workbench.action.closeActiveEditor"]
    },
    //workbench.action.closeOtherEditors
    {
      "before": ["<space>", "c", "o"],
      "commands": ["workbench.action.closeOtherEditors"]
    },
    //workbench.action.closeRightEditors
    {
      "before": ["<space>", "c", "r"],
      "commands": ["workbench.action.closeEditorsToTheRight"]
    },

    // quick open
    {
      "before": [
        "<leader>",
        "o"
      ],
      "commands": [
        "workbench.action.quickOpen"
      ]
    },

    // find char in all files(fing in all files)
    {
      "before": ["<leader>", "f", "a"],
      "commands": ["workbench.action.findInFiles"]
    },

    // format document 
    {
      "before": [
        "<leader>",
        "f",
        "m",
      ],
      "commands": [
        "editor.action.formatDocument"
      ]
    },
  ],
  "vim.insertModeKeyBindings": [
    // 退出插入模式
    {
      "before": [
        "j",
        "k"
      ],
      "after": [
        "<Esc>"
      ]
    }
  ],
  "vim.visualModeKeyBindingsNonRecursive": [
    // Stay in visual mode while indenting
    {
      "before": [
        "<"
      ],
      "commands": [
        "editor.action.outdentLines"
      ]
    },
    {
      "before": [
        ">"
      ],
      "commands": [
        "editor.action.indentLines"
      ]
    },
    // Move selected lines while staying in visual mode
    {
      "before": [
        "J"
      ],
      "commands": [
        "editor.action.moveLinesDownAction"
      ]
    },
    {
      "before": [
        "K"
      ],
      "commands": [
        "editor.action.moveLinesUpAction"
      ]
    },
    // toggle comment selection
    {
      "before": [
        "leader",
        "c"
      ],
      "commands": [
        "editor.action.commentLine"
      ]
    },
    {
      "before": [
        "H"
      ],
      "after": [
        "^"
      ]
    },
    {
      "before": [
        "L"
      ],
      "after": [
        "$"
      ]
    },
  ],
  "vim.digraphs": {},
  "vim.commandLineModeKeyBindings": [],
  "vim.commandLineModeKeyBindingsNonRecursive": [],
  // ==================vim config========================================
  "[jsonc]": {
    "editor.defaultFormatter": "vscode.json-language-features"
  },
  "[html]": {
    "editor.defaultFormatter": "vscode.html-language-features"
  },
  "security.workspace.trust.untrustedFiles": "open",
  "[json]": {
    "editor.defaultFormatter": "vscode.json-language-features"
  },
  "liveServer.settings.donotShowInfoMsg": true,
  "typescript.updateImportsOnFileMove.enabled": "always",
  "javascript.updateImportsOnFileMove.enabled": "always",
  "[python]": {
    "editor.defaultFormatter": "ms-python.python",
    "editor.formatOnType": true
  },
  // "python.defaultInterpreterPath": "C:\\Program Files\\Python310\\python.exe",
  // 忽略排除的文件
  "files.exclude": {
    "**/__pycache__": true,
    "**/.DS_Store": true,
    "**/.hg": true,
    "**/.idea": true,
    "**/.svn": true,
    "**/bin": true,
    "**/CVS": true,
    "**/obj": true,
    "**/Thumbs.db": true
  },
  "editor.suggestSelection": "first",
  "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
  // 编辑器字体大小
  "editor.fontSize": 14,
  "npm.keybindingsChangedWarningShown": true,
  "tabnine.experimentalAutoImports": true,
  "go.formatTool": "goimports",
  "cnblogsClientForVSCode.macos.workspace": "/Users/song/Documents/SimpRead",
  "[scss]": {
    "editor.defaultFormatter": "michelemelluso.code-beautifier"
  },
  "glsllint.glslangValidatorPath": "/Users/song/glslang-main-osx-Release/bin/glslangValidator",
  "cnblogsClientForVSCode.automaticallyExtractImages": "all",
  "svelte.enable-ts-plugin": true,
  "codeTranslator.baiduAppKey": "20230520001684049",
  "codeTranslator.baiduAppSecret": "9S0lRfJySUi8xPtipMBv",
  "tktbtranslation.baidu.appid": "20230520001684049",
  "tktbtranslation.baidu.keyBaido": "9S0lRfJySUi8xPtipMBv",
  "EnglishChineseDictionary.enableHover": true,
  "markdown.marp.enableHtml": true,
  "python.languageServer": "Pylance",
  "workbench.colorTheme": "Default Dark+",
  "explorer.confirmDelete": false,
  "editor.minimap.enabled": false,
  "editor.formatOnType": true,
  "editor.formatOnSave": true,
  "idf.espIdfPath": "/Users/song/esp/esp-idf",
  "idf.pythonBinPath": "/Users/song/.espressif/python_env/idf5.1_py3.11_env/bin/python",
  "idf.toolsPath": "/Users/song/.espressif",
  "idf.customExtraPaths": "/Users/song/.espressif/tools/xtensa-esp-elf-gdb/12.1_20221002/xtensa-esp-elf-gdb/bin:/Users/song/.espressif/tools/riscv32-esp-elf-gdb/12.1_20221002/riscv32-esp-elf-gdb/bin:/Users/song/.espressif/tools/xtensa-esp32-elf/esp-12.2.0_20230208/xtensa-esp32-elf/bin:/Users/song/.espressif/tools/xtensa-esp32s2-elf/esp-12.2.0_20230208/xtensa-esp32s2-elf/bin:/Users/song/.espressif/tools/xtensa-esp32s3-elf/esp-12.2.0_20230208/xtensa-esp32s3-elf/bin:/Users/song/.espressif/tools/riscv32-esp-elf/esp-12.2.0_20230208/riscv32-esp-elf/bin:/Users/song/.espressif/tools/esp32ulp-elf/2.35_20220830/esp32ulp-elf/bin:/Users/song/.espressif/tools/cmake/3.24.0/CMake.app/Contents/bin:/Users/song/.espressif/tools/openocd-esp32/v0.12.0-esp32-20230419/openocd-esp32/bin:/Users/song/.espressif/tools/ninja/1.10.2:/Users/song/.espressif/tools/esp-rom-elfs/20230320",
  "idf.customExtraVars": {
    "OPENOCD_SCRIPTS": "/Users/song/.espressif/tools/openocd-esp32/v0.12.0-esp32-20230419/openocd-esp32/share/openocd/scripts",
    "ESP_ROM_ELF_DIR": "/Users/song/.espressif/tools/esp-rom-elfs/20230320/"
  },
  "idf.gitPath": "git",
  "files.watcherExclude": {
    "**/obj": true
  },
  "json.format.enable": false
}