comments 2

Keeping code formatted the easy way

If you’re like me, you prefer to have your code tidy, and being a lazy guy, you have defined a ReSharper Code Cleanup template. The problem however, is that you might forget to run the Code Cleanup command every time you change the file. So I decided to go ahead and automate that by building a Visual Studio extension which will run the Silent Code Cleanup command every time a file in a solution is saved.

Extension Manager

The profile to use is defined in the box signaled below (ReSharper 6.1 shown here):

ReSharper Options

The addin should be compatible with Visual Studio 2010 and 2012, as well as any version of ReSharper.

The code for the addin can be found in my GitHub account.

  • That is not the goal of this addin. The only thing this addin does is to subscribe to the File/Save event and to perform a Reformat Code command upon that event. The goal being to not have to remember to reformat code yourself. As long as the addin is enabled, it will have that behavior.

  • I do not really get it how this is should work. If I open the resharper options I do not see any profile (in VS 2012, resharper 7.1). Any suggestions?