1

Hi I'm using VS Code for TypeScript and JavaScript. Standart autoformat create code like this

if(ind){
 // code
}

but I don't like this :), how to set autoformat as

if(ind)
{
    // code
}
Shaminder Singh
  • 1,283
  • 2
  • 18
  • 31
Lazar Krstic
  • 91
  • 2
  • 8
  • try using => Ctrl + K + D – cracker Mar 11 '16 at 12:15
  • 1
    Ctr + K + D is for Visual Studio. In Visual Studio Code it's Alt/Option+ Shift + F. But this will not change how Visual Studio Code formats brackets. I do not think it's possible. – henrikmerlander Mar 11 '16 at 12:22
  • Semi duplicate of this question, but the other way around: [How do I set up VSCode to put curly braces on a new line?](http://stackoverflow.com/questions/32900921/how-do-i-set-up-vscode-to-put-curly-braces-on-a-new-line) Unfortunately, it doesn't look like it's possible to specify formatting options in VSCode at the moment. – Yannick Meeus Mar 11 '16 at 15:34

2 Answers2

1

This is currently not possible with VsCode, but there is an issue tracking the problem and here's the actual code fix.

Keep in mind that this is from the development branch, so the behavior and settings may change, but I believe the settings you will want are:

javascript.format.placeOpenBraceOnNewLineForControlBlocks and/or javascript.format.placeOpenBraceOnNewLineForFunctions

This feature should make it into an official release shortly, but if you want the try out bleeding edge features you can always build VsCode from the source.

Matt Bierner
  • 58,117
  • 21
  • 175
  • 206
1

for TypeScript in settings.json

// Place your settings in this file to overwrite default and user settings.
{
    "typescript.format.placeOpenBraceOnNewLineForControlBlocks": true,
    "typescript.format.placeOpenBraceOnNewLineForFunctions": true
}

and autoformat!

Lazar Krstic
  • 91
  • 2
  • 8