ReSharper 2016.1 Help

Running Code Cleanup

ReSharper | Edit | Cleanup Code
Ctrl+Alt+F
ReSharper_CleanupCode

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. Select the scope where you want to cleanup code:
    • Make a selection in the editor to cleanup code in the selection.
    • Set the caret anywhere in the file to cleanup code in the file.
    • Select one or more items in the Solution Explorer to cleanup code in files under these items and their child items.
  2. Do one of the following:
    • Press Ctrl+Alt+F or choose ReSharper | Edit | Cleanup Code in the main menu .
    • Right-click anywhere in the text editor or right-click the selection and choose Cleanup Code in the context menu.
  3. In the Code Cleanup dialog box that opens, go to 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.
  4. 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:
    • Press Ctrl+Alt+F or choose ReSharper | Edit | Cleanup Code in the main menu .
    • 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

ReSharper | Edit | Silent Cleanup Code
Ctrl+Shift+Alt+F
ReSharper_SilentCleanupCode

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+Shift+Alt+F or choose ReSharper | Edit | Silent Cleanup Code in the main menu .

See Also

Last modified: 19 August 2016