VS Code中提升效率的实用快捷键(中英双语版)
熟练掌握VS Code的键盘快捷键,能大幅提升编码效率。除了操作系统通用的基础快捷键外,VS Code还有许多专属快捷键。本文通过中英双语对照,整理常用高效快捷键及功能解析,帮助你快速成为VS Code高效用户。
一、基础通用快捷键(Basic Universal Shortcuts)
You're likely already familiar with some of the basic shortcuts, which are inherited from your operating system. Shortcuts like Ctrl + S to save, Ctrl + C to copy, and Ctrl + V to paste all work in VS Code.
你可能已经熟悉一些从操作系统继承的基础快捷键,例如Ctrl + S(保存)、Ctrl + C(复制)和Ctrl + V(粘贴),这些在VS Code中均适用。
二、VS Code专属高效快捷键(VS Code-Specific Productivity Shortcuts)
But there's a few that are application specific and can still level up your productivity. It's worth noting that some of these shortcuts may differ by operating system.
但有一些是应用程序专属的快捷键,能显著提升你的效率。需要注意的是,部分快捷键可能因操作系统不同而有所差异。
1. 运行配置的格式化工具(Run Configured Formatter)
For example, Shift + Alt + F will run your configured formatter (such as prettier, for a JavaScript project) on the currently opened file.
例如,Shift + Alt + F会对当前打开的文件运行配置的格式化工具(如JavaScript项目中的Prettier)。
2. 全局搜索与替换(Global Search and Replace)
Or Ctrl + Shift + F (Windows), or Cmd + Shift + F (Mac), to search the text contents of all the files in your workspace. Then Ctrl + Shift + H (Windows), or Cmd + Shift + H (Mac), if you want to run a find-and-replace.
Windows系统使用Ctrl + Shift + F、Mac系统使用Cmd + Shift + F,可搜索工作区中所有文件的文本内容;若要执行查找替换,Windows系统用Ctrl + Shift + H,Mac系统用Cmd + Shift + H。
3. 删除当前行(Delete Current Line)
If you need to remove a line, Ctrl + Shift + K (Windows), or Cmd + Shift + K (Mac), will delete it.
若需删除一行,Windows系统按Ctrl + Shift + K,Mac系统按Cmd + Shift + K即可删除当前行。
4. 隐藏侧边栏(Hide Sidebar)
Need some extra room for all your code? Ctrl + B (Windows), or Cmd + B (Mac), will hide the sidebar - which has the file list and extensions menu.
需要更多代码显示空间?Windows系统按Ctrl + B,Mac系统按Cmd + B,可隐藏包含文件列表和扩展菜单的侧边栏。
5. 调整编辑器缩放比例(Adjust Editor Scaling)
Or maybe you just can't see your code? Ctrl + plus (Windows), or Cmd + plus (Mac), will increase the scaling of the editor, and Ctrl + minus (Windows), or Cmd + minus (Mac), will decrease it.
看不清代码?Windows系统按Ctrl + 加号、Mac系统按Cmd + 加号可增大编辑器缩放比例;Windows系统按Ctrl + 减号、Mac系统按Cmd + 减号可减小缩放比例。
6. 打开命令面板(Open Command Palette)
Finally, if you forget any of these shortcuts, you always have Ctrl + Shift + P (Windows), or Cmd + Shift + P (Mac), which opens the command palette for you to select whatever you may need.
最后,若忘记任何快捷键,Windows系统按Ctrl + Shift + P,Mac系统按Cmd + Shift + P,可打开命令面板,从中选择所需功能。
三、快捷键使用小贴士(Shortcut Usage Tip)
With this knowledge, and maybe a little practice, you are well on your way to becoming a VS Code power user.
掌握这些知识并稍加练习,你就能逐步成为VS Code高效用户。建议将常用快捷键整理成备忘录,初期刻意练习,形成肌肉记忆后编码效率会显著提升。
四、双语测验(Bilingual Quiz)
检验一下你的学习成果吧!欢迎在评论区留下答案~(Test your learning results! Feel free to leave your answers in the comments~)
1. Which Windows keyboard shortcut is used to run the configured formatter on the currently opened file in VS Code?(VS Code中,哪个Windows快捷键用于对当前打开的文件运行配置的格式化工具?)
-
Ctrl + F
-
Shift + Alt + F
-
Ctrl + Shift + F
-
Alt + F4
2. What function does the keyboard shortcut Ctrl + Shift + K (Windows/Linux) or Cmd + Shift + K (macOS) perform in VS Code?(VS Code中,快捷键Ctrl + Shift + K(Windows/Linux)或Cmd + Shift + K(macOS)的功能是什么?)
-
Opens the command palette.(打开命令面板。)
-
Increases the editor's text size.(增大编辑器文本大小。)
-
Deletes the current line.(删除当前行。)
-
Hides the sidebar.(隐藏侧边栏。)
3. Which Windows keyboard shortcut opens the command palette in VS Code?(VS Code中,哪个Windows快捷键打开命令面板?)
-
Ctrl + P
-
Ctrl + Shift + P
-
Alt + F4
-
Ctrl + Space