I’m currently working porting a library into another open source project. As I have heavily extended the library my primary goal was to make it work and then compliant to the coding guidelines. A lot of my code contained in the library had automatically generated (with R#) interface implementations which contained blank lines between the curly braces. As you might know this is not StyleCop compliant. Wonderfully I was able to address the issues with the VS2010 Search + Replace dialog and tagged expressions. See how…
{:b^8\{\n}:b^12\n{:b^8\}}
\1\2
{ expression } | Defines a tagged expression. Each occurrence is enumerated with n+1. |
:b | Defines a white space or a tab. |
item^n | Defines the number of times the item occurs. |
\{ | Opening curly braces |
\} | Closing curly braces |
\n | Newline |
So we can read the expression above like:
Match opening and curly braces which are indented with eight white spaces or tabs followed by a new line and and indented line with twelve white spaces or tabs. Group the opening curly braces with indentation including the new line into a tagged expression \1 and group the closing curly braces with indentation into a tagged expression \2. Replace the matched text with tagged expression one and tagged expression two.
This saved me a hell of a lot of time!