Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

configure prettier to push curly braces on new lines & not clear empty lines

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 }.

like image 405
Sohail Avatar asked Mar 29 '20 14:03

Sohail


1 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.

like image 173
ultraGentle Avatar answered Nov 03 '22 13:11

ultraGentle