【最佳实践】VSCode + Vim = 效率之神
Contents
导语
在 Visual Studio Code 中引入 Vim 模式,无疑可以极大程度上提高个人的编码效率。
I. VSCodeVim
VSCodeVim 是一款 vim 模拟器,它将 vim 的大部分功能都集成在了 VSCode 中,即一个嵌入在 VSCode 中的 vim。
正是由于 VSCodeVim 本质上只是一个 Vim 模拟器,而非真正的 Vim,导致原生 Vim 中的有些功能并不支持,具体支持情况见 roadmap。 尽管它现在还无法完全模拟 Vim,但这依然不妨碍它的优秀。
Status | Command |
---|---|
✅ | Normal Mode |
✅ | Insert Mode |
✅ | Visual Mode |
✅ | Visual Line Mode |
✅ | Number Prefixes |
✅ | . Operator |
✅ | Searching with / and ? |
✅ | Correct Undo/Redo |
⚠ | Command Remapping |
⚠️ | Marks |
✅ | Text Objects |
✅ | Visual Block Mode |
✅ | Replace Mode |
✅ | Multiple Select Mode |
⚠ | Macros |
⚠ | Buffer/Window/Tab |
✅ - command done
⚠️ - some variations of the command are not supported
II. 安装
只需在 VSCode 的插件商店搜索 vim
就能找到该插件.
关闭 Mac 的重复键
当使用 Mac 时,需要输入以下代码,用以关闭 Mac 的重复键
|
|
III. 文件配置详解
VSCodeVim 的相关配置文件是放在 settings.json
中,而不是 vimrc
文件.
- 对于非代码编辑区的热键将其定义在
keybindings.json
中 - 对于代码编辑区且属于 vim 的热键将其定义在
settings.json
文件中
1. 基础配置
|
|
2. 快捷键配置
NORMAL Mode
|
|
INSERT Mode
|
|
VISUAL Mode
|
|
COMMAND LINE Mode
|
|
`leader` 键注意事项
leader
键只在代码编辑区域生效,它无法做到全 VSCode 生效3. 资源管理配置
keybindings.json
定义对于非代码编辑区的热键.
|
|