ReSharper 2016.1 Help

Move Type to Another File

ReSharper | Refactor | Move…

This refactoring helps you move the selected non-nested type from the current file to any existing file or to a new file. If you are moving to a new file, the new file is created automatically. If there are no more types in the current file, it can be removed. All necessary imports are moved with the type. All imports that are no longer necessary are removed from the original file.

If you need to move a nested type, you can first apply the Move Type to Outer Scope refactoring.

To move a type to another file

  1. Select a type in one of the following ways:
    • In the editor, set the caret at the name of a type.
    • Select a type in the Solution Explorer.
    • Select a type in the File Structure Window.
    • Select a type in the Class View.
    • Select a type in the Object Browser.
    • Select a type in the type dependency diagram.
  2. Do one of the following:
    • Press F6 and then choose Move to Another File
    • Press Ctrl+Shift+R and then choose Move to Another File
    • Right-click and choose Refactor | Move to Another File on the context menu.
    • Choose ReSharper | Refactor | Move… in the main menu.
    The Move to Another File dialog will open.
  3. Type a file name in the New file name text box. You can specify the name for an existing file or a new one. In the latter case, the new file is created in the current project or folder.
  4. To apply the refactoring, click Next.
  5. If no conflicts are found, ReSharper performs the refactoring immediately. Otherwise, it prompts you to resolve conflicts.
ReSharper. Move to another file refactoring

This feature is supported in the following languages/technologies:

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

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

See Also


Last modified: 19 August 2016