IntelliJ IDEA 2018.1 Help

Move and Copy refactorings

The Copy refactoring lets you create a copy of a class in a different package. It also lets you create a copy of a file, directory or package in a different directory or package.

Perform copy refactoring

  1. Select an item you want to refactor. (For example, class in the editor or file in the Project tool window.
  2. Select Refactor | Copy (F5)
  3. In the dialog that opens, specify the name and location for your copy, and click OK.

The Move refactoring lets you move packages and classes between the source roots of a project, class members to other classes and inner classes to upper hierarchy levels.
For example, you can perform the move refactoring on method or field if it is used more in another class than in its own class.

Perform move refactoring

  1. Select an item you want to move.
  2. Select Refactor | Move (F6).
  3. In the dialog that opens depending on the item you have selected for your refactoring, specify the appropriate options and click Refactor (OK for a package). You can also click Preview, if available, to preview the potential changes.
Last modified: 24 July 2018

See Also