Skip to content

📒 快捷键

Who Uses The Keyboard To Navigage?

  • Power users who are able to use a mouse but find it quicker to use a keyboard.

掌握快捷键是提高工作效率的重要手段。这里收集我日常使用的快捷键。

VSCode

  • 导航:

    功能 Windows Linux macOS
    返回 Alt+Right Ctrl+Alt+- Ctrl+-
    前进 Alt+Left Ctrl+Shift+- Ctrl+Shift+-
    定义 F12 F12 F12
    • 实例

      功能 Windows Linux macOS
      新建实例 Ctrl+Shift+N ?
      关闭实例 Ctrl+Shift+W ?
    • 标签页

      功能 Windows Linux macOS
      切换标签页 Ctrl+Tab ? Ctrl+Tab ?
      关闭标签页 Ctrl+F4 ? Ctrl+W ?
      重新打开关闭的标签页 Ctrl+Shift+T Ctrl+Shift+T ?
    • 标签页组

      功能 Windows Linux macOS
      切换到第 1 组 Ctrl+1
      关闭组 Ctrl+K, Ctrl+W
  • 终端

    功能 Windows Linux macOS
    打开终端 ++ctrl+`++
    新建终端 ++ctrl+shift+`++
  • 侧边栏搜索

    功能 Windows Linux macOS
    打开侧边栏搜索 Ctrl+Shift+F
    打开文件 Ctrl+P
    打开符号 Ctrl+Shift+O
    打开 Git Ctrl+Shift+G
    打开扩展 Ctrl+Shift+X
  • 编辑

    功能 Windows Linux macOS
    格式化代码 ? Ctrl+Shift+I Option+Shift+F
    列选择 Shift+Alt ? ?
    插入光标 Alt+Left Button ? ?

Vim 插件

VSCode Vim 插件集成了一些常用的功能:

  • 特殊跳转功能(VSCode 有而 Vim 插件没有):

    • gd 定义(definition)
    • gq - on a visual selection reflow and wordwrap blocks of text, preserving commenting style. Great for formatting documentation comments.
    • af Visual 模式,扩大选区范围到上一层,选择代码块时非常好用
    • gh 获得提示(Hint)
  • surround:

    在 Normal 模式下的常用命令加上 s 使用 surround:

    功能 用法
    添加 ys<motion><符号>

    d 删除,c 替换,S 在 Visual 模式下使用。

    举例,要添加 Markdown 粗体标记,可以这么做:

    ys2w* // 为两个 word 添加 * 环绕
    . // 重复上面的动作
    

    对于中文,使用行选模式比较便捷:

    V<move>S<symbol>
    

    然而由于未支持 repeat.vim,所以行选模式下要重复环绕字符,需用 b 等移动回选区开头。

    暂不支持 $ 等符号

    关注 2025 年 3 月的 PR 合并:Add $ as a surround character (#8895) by cjohnson19 · Pull Request #9525 · VSCodeVim/Vim

    环绕用法详解:VIM学习笔记 环绕字符编辑(surround)