YouTip LogoYouTip

Pycharm File

PyCharm provides powerful file management features, allowing developers to efficiently organize project structure. This section will provide a detailed introduction to file and folder creation, moving, renaming, searching, and other operations. * * * ## **1. Basic File and Folder Operations** ### **1.1 Creating New Files/Folders** #### **Method 1: Right-click Menu Creation** 1. Right-click the target directory in the **Project Tool Window (Project View)** 2. Select: * **New β†’ Python File** (creates `.py` file) * **New β†’ Directory** (creates folder) * Other file types (HTML, JSON, etc.) !(#) #### **Method 2: Keyboard Shortcut Creation** * **New File**: `Alt + Insert` (Windows/Linux) / `⌘N` (Mac) * **New Directory**: Same operation, select "Directory" * * * ### **1.2 Renaming Files/Folders** #### **Safe Rename (Recommended)** !(#) 1. Select file β†’ Right-click β†’ **Refactor β†’ Rename** 2. Or use keyboard shortcut: `Shift + F6` 3. Enter new name β†’ Press `Enter` to confirm **Advantages**: * Automatically updates all references to the file in code * Avoids import errors caused by manual renaming #### **Direct Rename (Not Recommended)** * Right-click β†’ **Rename** (may break code references) * * * ### **1.3 Moving Files/Folders** !(#) #### **Safe Move (Recommended)** 1. Select file β†’ Right-click β†’ **Refactor β†’ Move** 2. Or keyboard shortcut: `F6` 3. Select target directory β†’ Click **Refactor** **Effect**: * Automatically fixes all import paths * For example: moving `utils/helper.py` to `core/`, all `from utils.helper import xxx` will automatically update to `from core.helper import xxx` #### **Drag and Drop Move (Not Recommended)** * Direct dragging may cause import path errors * * * ### **1.4 Deleting Files/Folders** #### **Safe Delete** !(#) 1. Select file β†’ Right-click β†’ **Refactor β†’ Safe Delete** 2. Or keyboard shortcut: `Alt + Delete` 3. PyCharm will check if any code references the file β†’ Confirm deletion #### **Normal Delete** * Right-click β†’ **Delete** (won't 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** 1. **Global Search**: `Ctrl + Shift + F` (Mac: `⌘ + Shift + F`) * Supports regular expressions, case matching, file type filtering 2. **Search in Current File**: `Ctrl + F` (Mac: `⌘ + F`) #### **Replace Operations** 1. **Global Replace**: `Ctrl + Shift + R` (Mac: `⌘ + Shift + R`) 2. **Replace in Current File**: `Ctrl + R` (Mac: `⌘ + R`) * * * ### **2.3 File Comparison** 1. Select two files β†’ Right-click β†’ **Compare Files** 2. Or use **Version Control Tools** to view file modification differences * * * ## 3. Advanced File Management Tips ### **3.1 File Templates** **Customize default content when creating new files**: 1. **Settings β†’ Editor β†’ File and Code Templates** !(#) 2. Select **Python Script**, modify the template: #!/usr/bin/env python # -*- coding: utf-8 -*- """ @Author: ${USER} @Date: ${DATE} @Description: """ def main(): pass if __name__ == '__main__': main() !(https
← Pycharm Run DebugPycharm Start Intro β†’