Braces on new lines in Visual Studio Code
Here there be dragons: Some people prefer their braces on the same line, some prefer them on the next line. If you're in the latter camp then the default in Visual Studio Code will annoy you - it's easy enough to change though.
Start off by opening Visual Studio Code and then click on the small "cog" icon at the bottom left of the screen:
This will bring up the settings editor:
Once this is open it's a simple matter to search for the relevant settings (for me, anyway!), which are:
- javascript.format.placeOpenBraceOnNewLineForControlBlocks
- javascript.format.placeOpenBraceOnNewLineForFunctions
You can search on 'placeOpenBraceOnNewLine' which will return both of these, along with their TypeScript counterparts, which can then be added to the "User Settings" on the right-hand side. If you're dealing with one project where you have to match (or want to enforce!) conventions, you can set these values in the "Workspace Settings" tab to have them only apply to that workspace.
For User Settings, you'll end up with an editor that looks something like this (assuming you haven't got any other setting customisations):
{ "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe", "javascript.format.placeOpenBraceOnNewLineForControlBlocks": true, "javascript.format.placeOpenBraceOnNewLineForFunctions": true, }