PyCharm File and Folder Operations
PyCharm provides powerful file management features that let developers organize project structures efficiently.
This section details operations such as creating, moving, renaming, and searching for files and folders.
1. Basic file and folder operations
1.1 Create a new file/folder
Method 1: Create via the right-click menu
-
in Project tool window (Project View) Right-click the target directory in it
-
Select:
New -> Python File(Create .py file)
New -> Directory(Create folder)
Other file types (HTML, JSON, etc.)
New -> Python File(Create .py file)
New -> Directory(Create folder)
-Other file types (HTML, JSON, etc.)

Method 2: Create via keyboard shortcut
-
New file:
Alt + Insert(Windows/Linux) /⌘N(Mac) -
New directory: Same as above, select 'Directory'
1.2 Rename files/folders
Safe rename (recommended)

-
Select the file -> right-click -> Refactor -> Rename
-
Or use the keyboard shortcut:
Shift + F6 -
Enter new name → press
EnterConfirm
Advantage:
-
Automatically update all code that references the file
-
Avoid import errors caused by manual renaming
Direct rename (not recommended)
-
Right-click -> Rename(may break code references)
1.3 Move files/folders

Safe move (recommended)
-
Select the file -> right-click -> Refactor -> Move
-
Or the shortcut:
F6 -
Select the target directory -> click Refactor
effect:
-
Automatically fix all import paths
-
For example: move
utils/helper.pytocore/under, allfrom utils.helper import xxxwill be updated tofrom core.helper import xxx
Drag-and-drop move (not recommended)
-
Dragging files directly may cause import path errors
1.4 Delete files/folders
Safe delete

-
Select the file -> right-click -> Refactor -> Safe Delete
-
Or the shortcut:
Alt + Delete -
PyCharm checks whether any code references the file -> confirm deletion
Normal delete
-
Right-click -> Delete (Delete)(does not check references)
2. File content operations
2.1 Quick navigation
| Operation | Shortcut (Windows/Linux) | Shortcut (Mac) |
|---|---|---|
| Go to file | Ctrl + Shift + N |
⌘ + Shift + O |
| Go to class | Ctrl + N |
⌘ + O |
| Go to symbol (method/variable) | Ctrl + Alt + Shift + N |
⌘ + Option + O |
| Recently opened files | Ctrl + E |
⌘ + E |
2.2 Code search and replace

Search within project
-
Global search:
Ctrl + Shift + F(Mac:⌘ + Shift + F)
Supports regex, case matching, and file type filtering
Supports regex, case matching, and file type filtering
-
Search in current file:
Ctrl + F(Mac:⌘ + F)
Replace operations
-
Global replace:
Ctrl + Shift + R(Mac:⌘ + Shift + R) -
Replace in current file:
Ctrl + R(Mac:⌘ + R)
2.3 File comparison
-
Select two files -> right-click -> Compare Files
-
Or use Version control tools View file modification differences
3. Advanced file management tips
3.1 File templates
Customize the default content when creating new files:
-
Settings -> Editor -> File and Code Templates

-
Choice Python Script, modify the template:
#!/usr/bin/env python
-- coding: utf-8 --
""" @Author: ${USER} @Date: ${DATE} @Description: """
def main(): pass
if name == 'main': main()

3.2 Local history
PyCharm automatically records file modification history (no Git needed):
-
Right-click the file -> Local History -> Show History

-
Can restore versions from any point in time

3.3 File markers
-
Bookmarks:
-
Add bookmarks:
F11(line-level) /Ctrl + F11(with marker) -
View bookmarks:
Shift + F11
Add bookmarks:F11(line-level) / Ctrl + F11(with marker)
View bookmarks:Shift + F11
-
To-do comments:
will be called when the To-do tool window Centrally displayed in
4. Frequently asked questions
Q1: How to hide specific files/folders?
-
Right-click the file -> Mark Directory as → Excluded
-
Or edit
.idea/.gitignore
Q2: How to batch rename files?
-
Select multiple files ->
Shift + F6 -
Use pattern replacement (e.g.,
test_*.py → spec_*.py)
Q3: How to recover accidentally deleted files?
-
Right-click the project root -> Local History → Show History
-
Find the pre-deletion version -> restore
5. Quick reference table
| Operation | Shortcut (Win/Linux) | Shortcut (Mac) |
|---|---|---|
| New file | Alt + Insert |
⌘N |
| Rename | Shift + F6 |
⇧F6 |
| Move files | F6 |
F6 |
| Safe delete | Alt + Delete |
⌘Delete |
| Global search | Ctrl + Shift + F |
⌘ + Shift + F |
| Go to file | Ctrl + Shift + N |
⌘ + Shift + O |