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.
- 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.
-
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 so, 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.
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.
- Choose ReSharper | Options in the main menu.
- Open Code Editing | Code Cleanup options page.
- Select a profile in the Profile to use with silent cleanup drop-down list.
-
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
.
-
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.
