简体   繁体   中英

How to influence how VSCode formats source code?

Visual Studio gives you the possibility to configure custom formating rules for each language. 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)? Is there at least a way to tell Code to put curly brackets "always" on a new line in 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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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