vscode中使用vim文件的增删改查

501 阅读1分钟

安装插件

需要安装vim插件。

如何在不同的区域切换

C代表ctrl

  • 侧边栏焦点定位 <C-0> 打开关闭 <C-B>
  • 编辑区用 <C-1>
  • 终端打开关闭 <C-`>

文件/文件夹的增删改查如何操作

参考阿崔的设置 需要在keybindings.json中设置

含义
<C+;>可以在编辑区和侧边栏来回切换
C-q关闭工作区
C-b侧边栏关闭打开
焦点在侧边栏含义
a新建文件
shift+a新建文件夹
r重命名
d删除文件/文件夹
c剪切文件
y复制文件
// Place your key bindings in this file to override the defaults
[
    {
        "key": "ctrl+;",
        "command": "workbench.view.explorer",
        "when": "viewContainer.workbench.view.explorer.enabled"
    },
    {
        "key": "y",
        "command": "filesExplorer.copy",
        "when": "filesExplorerFocus && !inputFocus"
    },
    {
        "key": "c",
        "command": "filesExplorer.cut",
        "when": "filesExplorerFocus && !inputFocus"
    },
    {
        "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 && !explorerResourceIsRoot && !explorerResourceReadonly && !inputFocus"
    },
    {
        "key": "ctrl+q",
        "command": "workbench.action.closeActiveEditor"
    },
    {
        "key": "ctrl+b",
        "command": "-extension.vim_ctrl+b",
        "when": "editorTextFocus && vim.active && vim.use<C-b> && !inDebugRepl && vim.mode != 'Insert'"
    }
]


settings.json中设置

改键含义
H对应成^
L对应末尾g_
leader + r改名称
leader + n + d新建文件夹
leader + n + f新建文件
// visual模式下
"vim.visualModeKeyBindings": [
        {
                "before": [
                        "H"
                ],
                "after": [
                        "^"
                ]
        },
        {
                "before": [
                        "L"
                ],
                "after": [
                        "g",
                        "_"
                ]
        },
],
// insert模式下键映射
"vim.insertModeKeyBindings": [
        {
                "before": [
                        "j",
                        "j"
                ],
                "after": [
                        "<Esc>"
                ]
        }
],
// normal模式下
"vim.normalModeKeyBindingsNonRecursive": [
        {
                "before": [
                        "ctrl",
                        "q",
                ],
                "commands": [
                        "editor.action.closeActiveEditor"
                ]
        },
        {
                "before": [
                        "<leader>",
                        "r",
                ],
                "commands": [
                        "editor.action.rename"
                ]
        },
        {
                "before": [
                        "<leader>",
                        "n",
                        "d"
                ],
                "commands": [
                        "explorer.newFolder"
                ]
        },
        {
                "before": [
                        "<leader>",
                        "n",
                        "f"
                ],
                "commands": [
                        "explorer.newFile"
                ]
        },
        {
                "before": [
                        "H"
                ],
                "after": [
                        "^"
                ]
        },
        {
                "before": [
                        "L"
                ],
                "after": [
                        "g",
                        "_"
                ]
        },
        {
                "before": [
                        "<leader>",
                        "d"
                ],
                "after": [
                        "d",
                        "d"
                ]
        },
        {
                "before": [
                        "<C-n>"
                ],
                "commands": [
                        ":nohl"
                ]
        },
        {
                "before": [
                        "K"
                ],
                "commands": [
                        "lineBreakInsert"
                ],
                "silent": true
        }
],
"vim.operatorPendingModeKeyBindings": [
        {
                "before": [
                        "H"
                ],
                "after": [
                        "^"
                ]
        },
        {
                "before": [
                        "L"
                ],
                "after": [
                        "g",
                        "_"
                ]
        },
],