Formatting VSCode:如何在保存时自动格式化?
在Visual Studio代码中,保存文件时如何自动格式化源代码?通过设置Formatting VSCode:如何在保存时自动格式化?,formatting,visual-studio-code,vscode-settings,Formatting,Visual Studio Code,Vscode Settings,在Visual Studio代码中,保存文件时如何自动格式化源代码?通过设置 "editor.formatOnSave": true 由于editor.formatOnSaveMode具有选项modifications,因此只需格式化您修改的代码即可。当您更改其他人的代码时非常好 您也可以仅为一种特定语言设置它: "[python]": { "editor.tabSize": 4, "editor.inser
"editor.formatOnSave": true
由于editor.formatOnSaveMode
具有选项modifications
,因此只需格式化您修改的代码即可。当您更改其他人的代码时非常好
您也可以仅为一种特定语言设置它:
"[python]": {
"editor.tabSize": 4,
"editor.insertSpaces": true,
"editor.formatOnSave": true #
},
由于版本1.6.1,Vscode支持“保存时格式化”。它将自动使用已安装的相关格式化程序扩展来格式化整个文档。以下是更改保存设置时VS代码自动格式化的步骤:
以下是更改自动格式热键设置的步骤:
转到/.vscode/settings.json文件并粘贴到下面的代码
{
"editor.formatOnSave": true,
}
它将在保存时格式化代码。当formatonSave处于活动状态时,如果autosave处于启用状态,则应调整延迟参数。否则,您会一直使用format函数。有关空格和制表符的详细信息。保存时的格式有缺点,只是想提醒您。