ReSharper Help

Running Code Cleanup

ReSharper | Tools | Cleanup Code
Ctrl+Alt+F
Ctrl+E,F (silent cleanup)

ReSharper can apply code cleanup to an arbitrarily selected block of code, all code in the current file, all files in a directory, the current project, or even the current solution. Make sure that you select the right set of cleanup features by choosing the right cleanup profile.

To apply code cleanup in the selection or in the whole file

  1. Open a file in the text editor.
  2. Make a selection to apply code cleanup to, or, alternatively, do not select anything, in which case ReSharper will clean up the entire file.
  3. Do one of the following:
    • Choose ReSharper | Tools | Cleanup Code on the main menu.
    • Press Ctrl+Alt+F.
    • Right-click anywhere in the text editor (or right-click the selection) and choose Cleanup Code in the context menu.
    The Code Cleanup dialog box opens.
  4. In the Available Profiles area, select a profile to apply to your file or selection. You can glance through settings of a selected profile in the Selected Profile Details area. (If none of the suggested profiles suits you, click Edit Profiles to create a custom profile.
  5. Click Run.

You can clean up not only an individual file, but also multiple files in a directory, project or entire solution. To do so, you should run code cleanup from the Solution Explorer.

To apply code cleanup in multiple files, projects, or entire solution

  1. Select one or more items (files, directories, projects, or the solution) in the Solution Explorer.
  2. Do one of the following:
    • Choose ReSharper | Tools | Cleanup Code on the main menu.
    • Press Ctrl+Alt+F.
    • Right-click the selection and choose Cleanup Code in the context menu.
  3. Choose a cleanup profile as described above.
  4. Click Run.

Silent cleanup

You can launch code cleanup in the silent mode - that is, without displaying the Code Cleanup dialog box. Since in this case you won't be able to choose a profile explicitly, you have to assign some cleanup profile to use for the silent code cleanup.

To assign a profile for silent code cleanup

  1. Choose ReSharper | Options in the main menu.
  2. Open the Code Cleanup options: ReSharper | Options | Code Editing | Code Cleanup.
  3. Select a profile in the Profile to use with silent cleanup drop-down list.
  4. Click Save to apply the modifications and let ReSharper choose where to save them, or save the modifications to a specific settings layer using the Save To drop-down list. For more information, see Managing and Sharing ReSharper Settings.

To run code cleanup in silent mode

  1. Do one of the following:
    • To run silent code cleanup in a specific code file, open it in the text editor or select it in the Solution Explorer.
    • To apply silent code cleanup to a set of files (directory, project, or solution), select the corresponding item in the Solution Explorer.
  2. Press Ctrl+E,F.

See Also

Last modified: 30 June 2015