1

VS Code will do brace completion when a brace is entered, {. With VS Code one can manually do a regex replacement of [\s\n]*([{}]) with $1 with the intent of removing the whitespace before each brace. How can the brace completion action be connected to automatically do the regex replacement?

CW Holeman II
  • 4,661
  • 7
  • 41
  • 72
  • 1
    Could you edit in the purpose of the regex? What will this actually achieve? Just for clarity :) – Darryl Noakes Jun 05 '23 at 22:23
  • do you want to remove the whitespace that is before `{` or `}` – rioV8 Jun 05 '23 at 23:32
  • 1
    As in https://stackoverflow.com/questions/76375764/vs-code-regular-expression-white-space-including-newlines – CW Holeman II Jun 06 '23 at 00:14
  • Curiosity: what is this for? – Darryl Noakes Jun 06 '23 at 02:17
  • 1
    @darryl-noakes Software Tools http://cm.bell-labs.co/who/bwk/toolsbook/ has the closing brace at the same level as the content of the block. Have been using for decades. Placing the closing brace at the end of the line rather than on its own line helps to visually make the braces be even more like just punctuation. As with Python where one completely removes the visual clutter and just has the indenting. With today's editors and compilers being so effective at catching missing bits, this is an additional attempt to spend more effort on the content of the blocks and less on the formatting. – CW Holeman II Jun 06 '23 at 19:36

1 Answers1

0

Instead of this workaround, use the Astyle VSCode extension as shown in Format Curly Braces on End Previous Line in C++ VSCode

CW Holeman II
  • 4,661
  • 7
  • 41
  • 72