如何在Visual Studio代码(VSCode)中设置代码格式 [英] How do you format code in Visual Studio Code (VSCode)
问题描述
Ctrl + K + F 和 Ctrl + K Windows上的kbd> + D 在Visual Studio中用于格式化还是在Visual Studio代码编辑器中美化代码?
What is the equivalent of Ctrl + K + F and Ctrl + K + D on Windows in Visual Studio for formatting, or "beautifying" code in the Visual Studio Code editor?
推荐答案
可通过以下快捷方式在Visual Studio代码中使用代码格式:
The code formatting is available in Visual Studio Code through the following shortcuts:
- 在Windows上 Shift + < kbd> Alt + F
- 在Mac上 Shift + Option + F
- 在Linux上 Ctrl + Shift + I
- On Windows Shift + Alt + F
- On Mac Shift + Option + F
- On Linux Ctrl + Shift + I
或者,您也可以通过编辑器中提供的命令面板( Ctrl + )查找快捷方式以及其他快捷方式Shift + P (或在Mac上为 Command + Shift + P ),然后搜索 格式文档。
Alternatively, you can find the shortcut, as well as other shortcuts, through the 'Command Palette' provided in the editor with Ctrl +Shift+ P (or Command + Shift + P on Mac), and then searching for format document.
-
打开命令面板(获胜:F1或Ctrt + Shift + P)
Open command palette (Win: F1 or Ctrt+Shift+P)
查找更改语言模型
选择语言,例如 json
。现在应该突出显示语法。
Select language e.g. json
. By now syntax should be highlighted.
格式化文档(例如,打开命令面板->'格式化文档' )
Format document (e.g. Open Command Palette -> 'Format Document')
取消格式化
- 选择文本
- 命令面板->加入行
'显示图片'
'Show the pics'
这篇关于如何在Visual Studio代码(VSCode)中设置代码格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!