I need a (sed, awk) shell script or, even better, a Vim command to remove any blank lines following a line with a single opening curly bracket. For example,
void func()
{
foo();
}
void bar()
{
helloWorld();
}
should become
void func()
{
foo();
}
void bar()
{
helloWorld();
}
Any thoughts?
Try this:
A bit of explanation:
/^ *{/means search for 0 or more blank spaces before the first{.f=1).fis true and!NF(means there is no fields, i.e., the line is blank), skip line usingnext.NF{f=0}means toggle back the flag), the rest of the lines will not be affected until the next opening brace.