如何在 Visual Studio Code (VSCode) 中格式化代码? [英] How do you format code in Visual Studio Code (VSCode)?
问题描述
Ctrl + K + F 和 Ctrl + K的等价物是什么?kbd> + D 在 Windows 上的 Visual Studio 中用于格式化,或在 Visual Studio Code 编辑器中美化"代码?
在 Visual Studio Code 中可以通过以下快捷方式进行代码格式化:
- 在 Windows 上 Shift + Alt + F
- 在 Mac 上 Shift + Option + F
- 在 Linux 上 Ctrl + Shift + I
或者,您可以使用 Ctrl +Shift+ P 通过编辑器中提供的命令面板"找到快捷方式以及其他快捷方式(或 Command + Shift + P 在 Mac 上),然后搜索格式文档强>.
对于未保存的片段
打开命令面板(Win:F1 或 Ctrl+Shift+P)>
找到更改语言模型"
选择语言,例如
json
.现在语法应该突出显示.格式化文档(例如打开命令面板 -> '格式化文档')
取消格式
- 选择文本
- 命令面板 ->加入行
'显示图片'
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?
The code formatting is available in Visual Studio Code through the following shortcuts:
- On Windows Shift + Alt + F
- On Mac Shift + Option + F
- On Linux Ctrl + Shift + I
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.
For unsaved snippets
Open command palette (Win: F1 or Ctrl+Shift+P)
Find 'Change Language Model'
Select language e.g.
json
. By now syntax should be highlighted.Format document (e.g. Open Command Palette -> 'Format Document')
Unformat
- Select text
- Command Palette -> Join Lines
'Show the pics'
这篇关于如何在 Visual Studio Code (VSCode) 中格式化代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!