ReSharper Web Help

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, ASP.NET, HTML, JavaScript, and CSS code.

To apply Code Cleanup to the current file
  1. Open a file in the text editor, make a selection to apply Code Cleanup to, or, alternatively, do not select anything, in which case ReSharper will clean up the entire file.
  2. 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 a selection) and choose Cleanup Code in the context menu.
    The Code Cleanup dialog box opens.
  3. 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. See Creating Custom Profiles for specific guidelines.)
  4. 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+F.
    • Right-click the selected Solution Explorer 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 a default profile to use every time you run silent code cleanup.

To assign a profile for silent Code Cleanup
  1. Choose ReSharper | Options in the main menu.
  2. Open Code Editing | Code Cleanup options page.
  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 its item 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. Click Ctrl+Shift+Alt+F.

See Also

Concepts

Procedures

Reference