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,2932 gold badges18 silver badges31 bronze badges
asked Mar 11, 2016 at 11:44
3
  • try using => Ctrl + K + D Commented Mar 11, 2016 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. Commented Mar 11, 2016 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? Unfortunately, it doesn't look like it's possible to specify formatting options in VSCode at the moment. Commented Mar 11, 2016 at 15:34

2 Answers 2

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.

answered Mar 11, 2016 at 21:44
Sign up to request clarification or add additional context in comments.

1 Comment

Is this still the case? seems like adding these lines to my user settings don't do anything
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!

answered Apr 26, 2016 at 8:58

2 Comments

Could you please elaborate more your answer adding a little more description about the solution you provide?
The same applies for javascript

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.