PyCharm Edu 3.0 Help

Rename Refactorings

On this page:

Basics

Rename refactorings allow you to rename symbols with all the references to them in the code corrected automatically.

The following rename refactorings are available in PyCharm Edu:

  • Rename Class. The following usages are renamed:
    • Import statements
    • Qualified names of classes
  • Rename Method. The following usages are renamed:
    • All calls of the method.
    • All overridden/implemented methods in subclasses.
  • Rename Field.
  • Rename Function.
  • Rename Variable.
  • Rename Parameter. The following usages are renamed:
    • All usages of the parameter.
    • The corresponding param tag in documentation comment.
  • Rename CSS color value.
  • Rename File.
  • Rename Directory.

Example 1

BeforeAfter
Renaming method
def was_published_today(self): return self.pub_date.date () == datetime.date.today() }
def published_today(self): return self.pub_date.date () == datetime.date.today() }

Renaming a symbol

To rename a symbol, follow these general steps

  1. Select the item to be renamed.
    • To select a file, click the desired file in the Project tool window.
    • To select a symbol in the editor, place the caret at the name of the symbol to be renamed.
    • To select a symbol in the Project tool window, make sure that the members are shown, and then click the desired symbol.
    • To select a symbol in the Structure view, click the desired symbol in the Structure tool window.
  2. Choose Refactor | Rename on the context menu, or press Shift+F6.
  3. The subsequent behavior depends on the check box Enable in-place mode ( Settings | Editor ).
    • If this check box is selected, the suggested name appears right below the symbol in question. You can either accept suggestion, or type a new name. However, if you press Shift+F6 once more, PyCharm Edu will display the Rename dialog box with more options.
    • If this check box is not selected, the Rename dialog box opens immediately.

    The set of controls and their names depend on the type of the symbol to be renamed.

  4. Preview and apply changes.

Renaming a file or directory

To rename a file or directory

  1. Select a desired file in the Project tool window.
  2. Choose Refactor | Rename on the main or context menu or press Shift+F6.
  3. In Rename File dialog box that opens, specify the new file name. Select Search in comments and strings checkbox to let PyCharm Edu apply changes to comments and strings.
  4. Press Preview to observe possible changes in Find Tool Window. Press Refactor to proceed.

    PyCharm Edu finds all the occurrences of the file name and changes them respectively.

See Also

Last modified: 30 August 2016