I had to take over a c# project. The guy who developed the software in the first place was deeply in love with #region because he wrapped everything with regions.
It makes me almost crazy and I was looking for a tool or addon to remove all #region from the project. Is there something around?
I had to take over a c# project. The guy who developed the software
Share
Just use Visual Studio’s built-in “Find and Replace” (or “Replace in Files”, which you can open by pressing Ctrl + Shift + H).
To remove
#region, you’ll need to enable Regular Expression matching; in the “Replace In Files” dialog, check “Use: Regular Expressions”. Then, use the following pattern: “\#region .*\n“, replacing matches with""(the empty string).To remove
#endregion, do the same, but use “\#endregion .*\n” as your pattern. Regular Expressions might be overkill for#endregion, but it wouldn’t hurt (in case the previous developer ever left comments on the same line as an#endregionor something).Note: Others have posted patterns that should work for you as well, they’re slightly different than mine but you get the general idea.