PyCharm 4.0.0 Web Help

PyCharm extends search and replace capability to the entire project, or any directory with its nested hierarchy. Explore search results in the Find tool window.

On this page:

Finding a piece of text in all the files within a specified path
  1. On the main menu, choose Edit | Find | Find in Path, or press Ctrl+Shift+FCtrl+Shift+FCtrl+Shift+FCtrl+Shift+FCtrl+Shift+FCtrl+Shift+FCtrl+Shift+FCtrl+HShift ⌘ FControl Shift FControl H.
  2. In the Find In Path dialog box, specify the following options:
    • The text to find. Type the text explicitly, or specify a pattern using a regular expression, or select a previously used piece of text or a pattern from the recent history drop-down list.

      If you specify the search pattern through a regular expression, use the $n format in back references (to refer to a previously found and saved pattern).

    • Search scope (project , module or directory).
    • Search options (case sensitivity, whole words, and regular expressions).
  3. Click Find.

If the search takes too long time, click Background in the search progress window. In this case the search progress is indicated in the Status bar.

Replacing a piece of text in all the files within a specified path
  1. On the main menu, choose Edit | Find | Replace in Path, or press Ctrl+Shift+RCtrl+Shift+RCtrl+Shift+RCtrl+Shift+RCtrl+Shift+RCtrl+Shift+RCtrl+Shift+HCtrl+Shift+RShift ⌘ RControl Shift RShift ⌘ R.

    Alternatively, being in the Find In Path dialog box, press Ctrl+Shift+RCtrl+Shift+RCtrl+Shift+RCtrl+Shift+RCtrl+Shift+RCtrl+Shift+RCtrl+Shift+HCtrl+Shift+RShift ⌘ RControl Shift RShift ⌘ R to switch to Replace In Path dialog box.

  2. In the Replace In Path dialog box, specify the search and replace strings, the search options, and the scope. Type the search and replacement text explicitly, or specify patterns using regular expression, or select a previously used piece of text or a pattern from the recent history drop-down list.
    • If you specify the search and/or replacement text through a regular expression, use the $n format in back references (to refer to a previously found and saved pattern).
    • To use a backslash character \ in a regular expression, escape the meaningful backslash by inserting three extra backslashes in preposition: \\\\.
  3. Click Find. PyCharm displays the encountered occurrences of the search string in the Find tool window, selects the first occurence and opens the file with this occurrence in the editor and moves the focus to it. At the same time, PyCharm opens the Replace Usage dialog box. Do one of the following:
    • To have the selected occurence replaced, click Replace.
    • To preserve the selected occurrence and move to the next one, click Skip.
    • To have all the occurrences of the search string in the currently active tab replaced, click Replace All in This File.
    • To preserve the occurrences of the search string in the currently active tab (any) and move to the next file, click Skip to Next File.
    • To have all the detected occurrences replaced, click All Files.
    • To switch to the manual mode, click Preview. The Replace Usage dialog box closes and the focus moves to the Find tool window. Do one of the following:
      • Browse through the list of detected occurrences, select the ones you want to replace and then click Replace Selected.
      • To have all the occurrences changed click Replace All.
3.0+
Toggling between the find in path and replace in path dialog boxes
  • To switch from the Find In Path to Replace In Path dialog box, press Ctrl+Shift+RCtrl+Shift+RCtrl+Shift+RCtrl+Shift+RCtrl+Shift+RCtrl+Shift+RCtrl+Shift+HCtrl+Shift+RShift ⌘ RControl Shift RShift ⌘ R.
  • To switch from the Replace In Path to Find In Path dialog box, press Ctrl+Shift+FCtrl+Shift+FCtrl+Shift+FCtrl+Shift+FCtrl+Shift+FCtrl+Shift+FCtrl+Shift+FCtrl+HShift ⌘ FControl Shift FControl H.

See Also

Procedures:

Reference:

Web Resources: