ReSharper 8.0 Web Help

ReSharper | Tools | Cleanup Code
Ctrl+Alt+FCtrl+E,C
Ctrl+Shift+Alt+FCtrl+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.

Code Cleanup can work for C#, VB.NET, XML, XAML, ASP.NET, Razor, HTML, JavaScript, and CSS code.

To apply Code Cleanup at the current 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+FCtrl+E,C.
    • Right-click anywhere in the text editor (or right-click a 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 code file, but also all code files in a directory, project or entire solution. To do so, you should run Code Cleanup from the Solution Explorer.

To apply Code Cleanup via Solution Explorer
  1. Select an item (file, directory, project, or solution) in the Solution Explorer.
  2. Do one of the following:
    • Choose ReSharper | Tools | Cleanup Code on the main menu.
    • Press Ctrl+Alt+FCtrl+E,C.
    • Right-click the selected item 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 silent code cleanup.

Note

ReSharper does not make a default selection of the silent cleanup profile. It means that until you select a profile by yourself, ReSharper will open the Code Cleanup dialog box whenever you launch 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 the settings layer, or choose a particular settings layer in the Save To drop-down list. To learn more about saving ReSharper settings, see JetBrains .NET Tools Blog: Save or Save To in ReSharper Options.
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+Shift+Alt+FCtrl+E,F.

This feature is supported in the following languages/technologies:

C# VB.NET HTML ASPX Razor JavaScript TypeScript CSS XML XAML RESX Build Scripts
feature_available feature_available feature_available feature_available feature_available feature_available feature_available feature_available feature_available feature_available

Tip

The instructions and examples given here address the use of the feature in C#. For details specific to other languages, see the corresponding topics in the ReSharper by Language section.