Lazar Krstic Lazar Krstic - 7 months ago 42
Javascript Question

How to change code formatting in Visual Studio Code

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
}

Answer

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!