VSCODE中代码的自动格式

问题描述 投票:7回答:2

我是一名长期的视觉工作室开发人员,并且正在讨论VSCode。

我找到了“格式代码”快捷键(Shift + alt + f),但我希望每按一次“;”就会自动运行。有配置吗?

typescript visual-studio-code
2个回答
7
投票

您可以选择以下选项之一

"editor.formatOnType": false,
"editor.formatOnPaste": false,
"editor.formatOnSave": false

或者通过编辑editor.action.formatDocument创建自定义键盘快捷键。但是当我按下;时,我无法执行命令。你可以设置键盘快捷键,但我想你再也不能写;了:D


3
投票

要打开user and workspace settings,请使用以下VS Code菜单命令:

在Windows / Linux上 - “文件”>“首选项”>“设置”

在macOS上 - 代码>首选项>设置

将这些选项添加到配置设置的可编辑面板中:

"editor.formatOnPaste": true,
"editor.formatOnSave": true

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.