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
}
-
try using => Ctrl + K + Dcracker– cracker2016年03月11日 12:15:15 +00:00Commented Mar 11, 2016 at 12:15
-
1Ctr + 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– henrikmerlander2016年03月11日 12:22:09 +00:00Commented 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.Yannick Meeus– Yannick Meeus2016年03月11日 15:34:21 +00:00Commented Mar 11, 2016 at 15:34
2 Answers 2
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.
1 Comment
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!
2 Comments
Explore related questions
See similar questions with these tags.