Answer a question

I am using prettier with VSCode, How can I configure it to format my code like this :

function test() 
{

   if() 
      {

         MYCODE GOES HERE;

      }

}

I want the { and } on new lines, and an empty line after { and before }.

Currently, it moves the curly brackets to same lines if condition or function name, and also remove the empty lines after/before { and }.

Answers

Prettier is considered an " opinionated " formatter, which means it doesn't let you choose things like that. If you want more control over the formatting, you can use a different formatter.

The built-in VS code formatter allows you to do what you're looking for, just search the settings for " function new line " and similar options.

There are of course many other formatting extensions available in the VS code marketplace as well. Whichever you choose, you will have to select it has your default formatter in your VS code settings.

Logo

开发云社区提供前沿行业资讯和优质的学习知识,同时提供优质稳定、价格优惠的云主机、数据库、网络、云储存等云服务产品

更多推荐