在 Visual Studio Code 中自动格式化代码 [英] Automatically format code in Visual Studio Code

查看:68
本文介绍了在 Visual Studio Code 中自动格式化代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Visual Studio 的长期开发人员,正在使用 VS Code 进行说明.

I'm a long time visual studio developer and am stating with VS Code.

我找到了格式代码快捷方式(Shift + Alt + F),但我想让它运行每当我按下 ; 时自动.有没有相关配置?

I found the Format Code shortcut (Shift + Alt + F) but I want it to run automatically whenever I press ;. Is there a configuration for that?

推荐答案

您可以选择以下选项之一

You can choose one of the below options

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

或通过编辑 editor.action.formatDocument 创建自定义键盘快捷键.但是我发誓,无论何时按下 ;,都没有执行命令的选项.你可以设置一个键盘快捷键,但我猜你不能再写 ; 了 :D

Or create a custom keyboard shortcut by editing editor.action.formatDocument. But I AFAIK there is no option to execute the command whenever you press ;. You can set a keyboard shortcut, but I guess you're not able to write ; anymore then :D

这篇关于在 Visual Studio Code 中自动格式化代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆