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"{",'

- 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!

© 2020 Golden Syrup Games

  • Twitter Social Icon