Visual Studio Code - Change inline braces in snippets to newline braces


Situation

You’re a monster like me and have standardised on newline braces in PowerShell, but the vscode PowerShell extension has used inline braces.

Solution

  • Copy the snippets you use from %userprofile%\.vscode\extensions\ms-vscode.powershell-1.5.1\snippets\PowerShell.json
  • Add them to your user snippets for PowerShell (CTRL+SHIFT+P > Open User Snippets > PowerShell)
  • CTRL+F, regex mode
  • Find \{",
  • Replace with ",\n\t\t\t"{",

image

  • CTRL+, to open user settings, then add "editor.snippetSuggestions": "top"
  • Note: there are PowerShell user settings for code formatting, but I found these didn’t apply to snippets. Probably good to bang "powershell.codeFormatting.preset": "Allman" into there anyway
  • Save all and you’re good to go!

Videogames

Hey, do you like videogames? If so please check out my game Grab n' Throw on Steam, and add it to your wishlist. One gamemode is like golf but on a 256 km^2 landscape, with huge throw power, powerups, and a moving hole. Another is like dodgeball crossed with soccer except instead of balls you throw stacks of your own teammates. And there's plenty more!

See full gameplay on Steam!