VI Search and Replace Snippit

Since I haven’t programmed for a while, my formatting is rusty. I realized that I was inconsistant in how I was using spaces around my parenthesis in my code.

The “correct” formatting is to have a space after the opening parens and one before the closing parens.

Here are two quick vi searches to fix it up.

The first one looks for all open parens that are followed by any character except a closing parens or a space and adds a space:

%s!(\([^) ]\)!( \1!g

The second one looks for all closing parens that are proceeded by any character except an opening parens or a space and adds a space:

%s!\([^( ]\))!\1 )!g

Sure, now that I figured this out, I realize that it’s backwards from the style guide… Or maybe not. Perltidy adds spaces in the parens…

Also, I should probably just use Perltidy

In any case, I’m going to post this anyway, since I took the time to figure out the regex. 😛