vscode vim 快捷键汇总


需满足操作:

  1. 上下移动
  2. 按照 word 移动
  3. 选中增删改
  4. 查找字符/变量
  5. 移动、增加、复制、删除 行
  6. 选中多个相同的变量/字符
  7. 屏幕移动
  8. 增加多个光标
  9. 快速注释
    10.mark后的快速跳转

上下左右移动

CommandDescription
🔢 hleft (also: CTRL-H, BS, or Left key)
🔢 lright (also: Space or Right key)
0to first character in the line (also: Home key)
^to first non-blank character in the line
🔢 $to the last character in the line (N-1 lines lower) (also: End key)
gmto middle of the screen line
🔢 |to column N (default: 1)
🔢 f{char}to the Nth occurrence of {char} to the right
🔢 kup N lines (also: CTRL-P and Up)
🔢 jdown N lines (also: CTRL-J, CTRL-N, NL, and Down)
🔢 -up N lines, on the first non-blank character
🔢 +down N lines, on the first non-blank character (also: CTRL-M and CR)
🔢 _down N-1 lines, on the first non-blank character
🔢 Ggoto line N (default: last line), on the first non-blank character
🔢 gggoto line N (default: first line), on the first non-blank character

按照word移动

CommandDescription
🔢 wN words forward
🔢 WN blank-separated WORDs forward
🔢 eN words forward to the end of the Nth word
🔢 EN words forward to the end of the Nth blank-separated WORD
🔢 bN words backward
🔢 BN blank-separated WORDs backward
🔢 )N sentences forward
🔢 (N sentences backward
🔢 }N paragraphs forward
🔢 {N paragraphs backward

选中增删改

进入 insert mode 后就和之前的模式一样,快捷键有些是和原理的 vscode 一致,有些不一致。

visual mode

CommandDescription
vstart highlighting characters or stop highlighting
Vstart highlighting linewise or stop highlighting
CTRL-Vstart highlighting blockwise or stop highlighting
oexchange cursor position with start of highlighting

删除

CommandDescription
🔢 xdelete N characters under and after the cursor
🔢 Deldelete N characters under and after the cursor
🔢 Xdelete N characters before the cursor
🔢 d{motion}delete the text that is moved over with {motion}
{visual}ddelete the highlighted text
🔢 dddelete N lines
🔢 Ddelete to the end of the line (and N-1 more lines)
(change = delete text and enter Insert mode)
🔢 c{motion}change the text that is moved over with {motion}
{visual}cchange the highlighted text
🔢 ccchange N lines
🔢 Schange N lines
🔢 Cchange to the end of the line (and N-1 more lines)
🔢 shhchange N characters

复制

CommandDescription
"{char}use register {char} for the next delete, yank, or put
"*use register * to access system clipboard
:regshow the contents of all registers
:reg{arg} show the contents of registers mentioned in {arg}
🔢 y{motion}yank the text moved over with {motion} into a register
{visual}yyank the highlighted text into a register
🔢 yyyank N lines into a register
🔢 Yyank N lines into a register
🔢 pput a register after the cursor position (N times)
🔢 Pput a register before the cursor position (N times)
🔢 ]plike p, but adjust indent to current line
🔢 [plike P, but adjust indent to current line
🔢 gplike p, but leave cursor after the new text
🔢 gPlike P, but leave cursor after the new text

增加

CommandDescription
🔢 aappend text after the cursor (N times)
🔢 Aappend text at the end of the line (N times)
🔢 iinsert text before the cursor (N times) (also: Insert)
🔢 Iinsert text before the first non-blank in the line (N times)
🔢 gIinsert text in column 1 (N times)
giinsert at the end of the last change
🔢 oopen a new line below the current line, append text (N times)
🔢 Oopen a new line above the current line, append text (N times)

查找字符/变量

CommandDescription
🔢 /{pattern}[/[offset]]search forward for the Nth occurrence of {pattern} Currently we only support JavaScript Regex but not Vim’s in-house Regex engine.
🔢 ?{pattern}[?[offset]]search backward for the Nth occurrence of {pattern} Currently we only support JavaScript Regex but not Vim’s in-house Regex engine.
🔢 /repeat last search, in the forward direction {count} is not supported.
🔢 ?repeat last search, in the backward direction {count} is not supported.
🔢 nrepeat last search
🔢 Nrepeat last search, in opposite direction
# or *你还可以搜索整词,将光标移动到这个词语上,然后按向前搜索,或者#向后搜索。想要查找下一个匹配,再按或者#。

移动、增加、复制、删除 行

复制行
insert mode
alt + shift up/down
删除行
dd
移动行
insert mode
alt + up/down

选中多个相同的变量/字符

CRTL +D选中目标
shift + c /d 等 修改、删除目标
此时再按 v,可退出 visual 模式,再按 a/i插入光标
cursor 即可编辑全部目标

屏幕移动

CommandDescription
🔢 CTRL-Ewindow N lines downwards (default: 1)
🔢 CTRL-Dwindow N lines Downwards (default: 1/2 window)
🔢 CTRL-Ywindow N lines upwards (default: 1)
🔢 CTRL-Uwindow N lines Upwards (default: 1/2 window)
zz将当前行移动到屏幕中央

增加多个光标

in Visual block mode:

CommandDescription
Iinsert the same text in front of all the selected lines
Aappend the same text after all the selected lines

normal mode
alt + command + up / down(必须在 normal model,insert 和 visual 都不行)
then i or a

快速注释

command + /

切换 file

CTRL + TAB
CTRL + 12345

vscode 快捷键

CTRL + B 打开边栏

参考:https://github.com/VSCodeVim/Vim/blob/HEAD/ROADMAP.md

mark 跳转

m ——创建标记
’ ——移动到标记的文本行首
` ——移动到标记的光标位置
:marks ——列示所有标记
:delmarks ——删除指定标记
:delmarks! ——删除所有标记

宏的使用-复制p到下一行

宏录制的基本概念

宏(Macro)是Vim中的一组预先录制的命令序列,用户可以通过按下某个按键来重复执行这些命令。宏录制是将一系列的编辑操作记录下来,以便在后续的编辑过程中快速重放。

宏录制的步骤

录制宏的基本步骤如下:

  1. 进入正常模式。
  2. 按下 q 键开始录制宏。
  3. 按下一个字母键(如 a)来命名宏。
  4. 执行一系列编辑操作,这些操作将被记录下来。
  5. 按下 q键结束录制。

例如:

qa        " 开始录制宏,宏的名称为 'a'
iHello    " 进入插入模式并输入 'Hello'
<ESC>     " 返回正常模式
A World!  " 移动到行尾并追加 ' World!'
<ESC>     " 返回正常模式
q         " 结束录制

执行宏

执行宏的方法是按下 @ 键,然后输入宏的名称。例如,执行上述宏可以使用以下命令:

@a        " 执行宏 'a'

多次执行宏
要多次执行宏,可以使用 @@ 命令,这将重复上一次执行的宏,或使用计数前缀来指定执行次数。例如,执行宏 a 五次:

5@a       " 执行宏 'a' 五次

更多见详细内容

### VSCodeVim 扩展的快捷键配置与使用指南 VSCodeVim 扩展允许开发者在编辑器中模拟 Vim 的行为,从而提高开发效率。以下是关于如何配置和使用 VSCode Vim 扩展的一些关键点: #### 安装扩展 要安装 VSCodeVim 扩展,可以通过以下方式完成: 1. 打开 Visual Studio Code。 2. 进入 Extensions 市场 (Ctrl+Shift+X 或 View -> Extensions)。 3. 搜索 `Vim` 并点击 Install。 #### 配置文件设置 通过修改用户的 settings.json 文件可以自定义 Vim 行为。打开命令面板 (`Ctrl+Shift+P`) 输入 `Preferences: Open Settings (JSON)` 来访问 JSON 设置文件。常见的配置项如下所示[^3]: ```json { "vim.easymotion": true, "vim.useSystemClipboard": true, "vim.insertModeKeyBindings": [ { "before": ["j", "k"], "after": ["<Esc>"] } ], "vim.normalModeKeyBindingsNonRecursive": [ { "before": ["<leader>", "d"], "commands": ["vscode.action.deleteRight"] } ] } ``` 上述代码片段展示了几个常用的配置选项: - `"vim.easymotion"` 启用了 EasyMotion 插件风格的功能。 - `"vim.useSystemClipboard"` 控制剪贴板的行为。 - 自定义按键绑定可通过 `insertModeKeyBindings` 和 `normalModeKeyBindingsNonRecursive` 实现特定需求。 #### 使用方法概述 一旦安装并设置了扩展,就可以利用标准的 Vim 键盘快捷键来导航、选择以及操作文本。例如,在正常模式下移动光标可以用 h/j/k/l;进入插入模式则按 i 键等基本操作均适用。对于更高级的操作,比如宏录制或者寄存器管理,则需进一步查阅官方文档获取支持详情[^4]。 另外值得注意的是,如果遇到某些区域被禁用显示灰色的情况(如 #ifdef),这通常不是由 Vim 导致而是 C/C++ IntelliSense 或其他相关插件引起的处理预处理器指令的结果[^1]。 #### 快捷键列表摘要 下面是一些重要的默认快捷键供参考: | 功能 | 默认快捷键 | | --- | --- | | 切换到 Normal Mode | Esc / Ctrl+[ | | 移动至行首/尾 | 0/$ | | 删除当前字符 | x | 以上仅列举部分基础功能表意示意实际应用远不止这些具体可根据个人习惯调整优化体验效果最佳[^5]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值