1. 格式化代码

这个快捷键可以帮助我们对代码进行锁进。

  • 在 Windows 上:Shift + Alt + F
  • 在 Mac 上:Shift + Option + F
  • 在 Ubuntu 上:Ctrl + Shift + I

注:可以在编码的任何时候使用它,但是在代码编写完成的时候用这个格式化一下代码会更好。

VS Code 常用的11个快捷键

2 向上/向下 复制行

  • 在 Windows 上:Shift + Alt + Up/Down
  • 在 Mac 上:Shift + Option + Up/Down
  • 在 Ubuntu 上:Ctrl + Shift + Alt + Up/Down

VS Code 常用的11个快捷键

3 单词选中

  • 在 Windows 上:Ctrl+ d
  • 在 Mac 上: Command + d
  • 在 Ubuntu 上: Ctrl+ d

如果你多次点击此快捷键,将会选中多个相同的关键字。

VS Code 常用的11个快捷键

4 打开关闭侧边栏

  • 在 Windows 上:Ctrl+ b
  • 在 Mac 上:Command + b
  • 在 Ubuntu 上:Ctrl+ b

有时候,文件里面的代码宽度比较大,关闭侧边栏可以有更大的代码可视范围。

VS Code 常用的11个快捷键

5 删除上一个词

  • 在 Windows 上:Ctrl + backspace
  • 在 Mac 上:Option + delete
  • 在 Ubuntu 上:Ctrl + backspace

这个功能在您输入错误时非常有用,你不需要按住 delete 一个个删。

VS Code 常用的11个快捷键

6 选中词

  • 在 Windows 上:Ctrl + Shift + 右键头 / 左键头
  • 在 Mac 上:Option + Shift + 右键头 / 左键头
  • 在 Ubuntu 上:Ctrl + Shift + 右键头 / 左键头

这个快捷键有助于快速选中并编辑。

VS Code 常用的11个快捷键

7 复制行

  • 在 Windows 上:Ctrl + Shift + d
  • 在 Mac 上:Command + Shift +d
  • 在 Ubuntu 上:Ctrl + Shift + d

复制行是一个非常强大的功能。

VS Code 常用的11个快捷键

8 删除行

  • 在 Windows 上:Ctrl + x
  • 在 Mac 上:Command + x
  • 在 Ubuntu 上:Ctrl + x

9 跳转到特定行

注:在文件中进行行跳转,你可以使用Ctrl + G ,然后输入要跳转的行号,当然,你也可以使用Ctrl + P,然后输入:和要跳转的行号。

  • 在 Windows 上:Ctrl + g
  • 在 Mac 上:Ctrl + g orCtrl + p
  • 在 Ubuntu 上:Ctrl + g

VS Code 常用的11个快捷键

10 拆分编辑框

  • 在 Windows 上:Shift + Alt + \ or 2,3,4
  • 在 Mac 上:Command + \ or 2,3,4
  • 在 Ubuntu 上:Shift + Alt + \ or 2,3,4

拆分编辑器可以使用拆分的快捷键,使用 123 也可以切换编辑器焦点。

VS Code 常用的11个快捷键

11 添加多个光标

  • 在 Windows 上:Ctrl + Alt + Up/Down
  • 在 Mac 上:Command + Alt + Up / Down
  • 在 Ubuntu 上:Ctrl + Alt + Up / Down

复制光标是 VS Code中的一个功能,可以节省很多时间。

VS Code 常用的11个快捷键

原文:https://medium.com/better-programming/20-vs-code-shortcuts-for-fast-coding-cheatsheet-10b0e72fd5d

https://mp.weixin.qq.com/s/t7TLBOcnOs0AkncCVsYr9Q

有很多快捷键可以满足你的需求, 在这里,作者列出了所有 VS Code 快捷键的 PDF 文件:
Linux:https://code.visualstudio.com/shortcuts/keyboard-shortcuts-linux.pdf
Window:https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf
macOS:https://code.visualstudio.com/shortcuts/keyboard-shortcuts-macos.pdf

相关文章:

  • 2021-10-07
  • 2021-12-25
  • 2021-06-14
  • 2021-10-19
  • 2021-11-15
  • 2021-12-16
猜你喜欢
  • 2021-06-19
  • 2022-01-18
  • 2021-12-23
  • 2021-12-12
  • 2021-09-07
  • 2021-10-28
  • 2021-11-16
相关资源
相似解决方案