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.
- Open a C#, VB.NET or XML code file in the text editor, make a selection to apply Code Cleanup to, or, alternatively, don't select anything, in which case ReSharper will clean up the entire file.
- 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.
- 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.) - 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 that, you should run Code Cleanup from the Solution Explorer.
- Select an item (file, directory, project, or solution) in the Solution Explorer.
- 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.
- Choose a cleanup profile as described above.
- Click Run.
You can launch Code Cleanup in 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.
- Choose ReSharper | Options | Tools | Code Cleanup.
- In the Code Cleanup tab, select a profile in the Profile to use with silent cleanup drop-down list.
- Click OK.
- 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.
- Click Ctrl+Shift+Alt+F.
