I would like to reformat code in an entire file from this brace style:
if (condition)
{
body;
}
… into this brace style1:
if (condition) {
body;
}
The bulk of the task should be accomplishable by relocating the opening braces. I would like to do something like
:%s/^M *{$/ {/
… but substitutions don't seem to work across line breaks.
Is there a way to make substitutions work across line breaks? If not, what is the next-best solution that does not involve an external command or plugin? (I'm more interested in text-editing technique than in specialized programming tools.)
1 No flame wars about the choice of brace style, please!