简体   繁体   English

如何影响VSCode格式的源代码?

[英]How to influence how VSCode formats source code?

Visual Studio gives you the possibility to configure custom formating rules for each language. Visual Studio使您可以为每种语言配置自定义格式规则。 For example, how curly brackets are place or where whitespaces get inserted. 例如,如何放置大括号或在何处插入空格。

Are there ways to configure the formatting in Visual Studio Code for each language (planned)? 有没有办法在Visual Studio Code中为每种语言(计划的)配置格式? Is there at least a way to tell Code to put curly brackets "always" on a new line in JavaScript? 至少有一种方法可以告诉Code在JavaScript中将“大括号”始终放在“换行符”上吗?

Yes, 是,

Open your user or workspace configuration, and put this inside: 打开您的用户或工作空间配置,并将其放入其中:

// Defines whether an open brace is put onto a new line for functions or not.
"javascript.format.placeOpenBraceOnNewLineForFunctions": true,

Make sure javascript formatting is enabled 确保启用了javascript格式

// Enable/disable default JavaScript formatter.
"javascript.format.enable": true,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM