Skip to main content

VS Code 功夫:常用快捷键(更多)

·652 字·2 分钟
工具 & 生产效率 vs code
Table of Contents
VS Code 功夫 - This article is part of a series.
Part 4: This Article

代码块 #

普通的文本选中:
 - 向左/右选中一个字母:⇧ → ⇧ ←
 - 向左/右选中一个词:⌥ ⇧ → ⌥ ⇧ ←
 - 向左/右选中至行首/尾:⌘ ⇧ → ⌘ ⇧ ←
当前代码块智能选中:⌃ ⇧ → ⌃ ⇧ ←
当前代码块智能删除括号:⌃ ⌘ ⌫
当前代码块合并&展开:⌘ ⌥ [ ⌘ ⌥ ],全局则用 ⌘ K 0 ⌘ K J
可以通过 #region #endregion 注释来自定义代码块
合并多行 Join line:⌃ J

注释 #

  • 增加/移除行注释:⌃ /
  • 增加/移除块注释:⇧ ⌃ A

代码 #

Symbol #

这里讲解一下符号 Symbol 指的是什么,它就是在代码中的方法、类或者是属性。

查看 Symbol 的声明 definition:F12
预览声明:⌃ + 鼠标悬停
跳去声明:双击 (如果在侧面打开:⌃ + ⌥ + 点击)
查看 Symbol 的具体实现 implementation:⌥ F12
查看 Symbol 的使用情况(当前 workspace):⌥ ␣
查看 Symbol 的引用 reference:⇧ F12
预览引用:⌥ F12
重构 Symbol,可以用 查找/替换 来修改 Symbol,不过更好的办法是选取后快捷键:F2

Intellisence #

常用

  • 自动补全:
  • 自动改错或 refactor:⌘ .
  • Refactor 菜单:⇧ ⌃ R
  • 补全提示:⌘ ␣

Debug #

  • toggle breakpoint: F9
  • start/continue: F5
  • restart:⌘ ⇧ F5
  • stop:⇧ F5
  • step into/out:F11 ⇧ F11
  • step over:F10

debug 过程中鼠标悬停可以显示 Symbol 当前值 或者 ⌃ K I

更多参考: Debugging

VS Code 功夫 - This article is part of a series.
Part 4: This Article