正文
🌍一、界面与外观
❄️1、主题与字体
-
修改主题:
File → Settings → Appearance & Behavior → Appearance → Theme
(推荐Darcula
深色主题)。 -
调整字体:
Editor → Font
,建议启用Font ligatures
(连字字体)提升代码可读性。 -
自定义图标主题:
Appearance & Behavior → Appearance → Use custom icons
。
❄️2、布局优化
-
隐藏工具栏: 右键顶部工具栏取消勾选
Toolbar
。 -
分屏编码: 右键标签页选择
Split Vertically/Horizontally
。
🌍二、编辑器优化
-
❄️代码补全与提示
-
智能补全: 默认快捷键
Ctrl + Space
,建议开启Editor → General → Code Completion → Show suggestions as you type
。 -
自动导包:
Editor → General → Auto Import
,勾选Add unambiguous imports on the fly
。
-
-
❄️代码风格
-
PEP8 规范:
Editor → Code Style → Python
,设置缩进为4空格,启用Wrap when typing reaches right margin
。 -
格式化代码: 快捷键
Ctrl + Alt + L
(Windows/Linux)或⌥⌘L
(Mac)。
-
-
❄️代码模板
文件模板:
Editor → File and Code Templates
,自定义新建文件时的默认内容(如添加作者、时间戳)。实时模板:
Editor → Live Templates
,使用预设模板(如main
生成if __name__ == '__main__'
)。
🌍三、项目配置
-
❄️Python 解释器
-
设置虚拟环境:
File → Settings → Project: <项目名> → Python Interpreter
→ 点击齿轮选择Add
,创建或指定已有虚拟环境。 -
依赖管理: 在解释器界面点击
+
安装包,或直接编辑requirements.txt
。
-
-
❄️项目结构
-
标记目录: 右键文件夹选择
Mark Directory as
(如Sources Root
标记为源码目录)。
-
🌍四、版本控制
-
❄️Git 集成
-
配置 Git 路径:
Version Control → Git
,指定 Git 可执行文件路径。 -
提交代码:
Ctrl + K
提交更改,勾选Reformat code
和Optimize imports
保持代码整洁。 -
解决冲突: 在冲突文件中使用
Ctrl + Shift + Alt + ←/→
快速跳转冲突点。
-
🌍五、插件推荐
-
❄️必备插件
-
Key Promoter X: 提示快捷键,帮助记忆操作。
-
Rainbow Brackets: 彩色括号匹配。
-
Database Navigator: 数据库连接工具。
-
Markdown: 增强 Markdown 支持。
-
-
❄️安装方式
-
File → Settings → Plugins
→ 搜索并安装。
-
🌍六、调试与运行
-
❄️调试配置
-
设置断点: 点击行号左侧区域,支持条件断点(右键断点设置条件)。
-
调试控制: 使用
F8
(Step Over)、F7
(Step Into)逐行调试。
-
-
❄️运行配置
-
环境变量: 在
Run/Debug Configurations
的Environment variables
中添加变量(如PYTHONPATH
)。
-
🌍七、实用技巧
-
快速搜索:
双击 Shift
全局搜索文件、类或操作。 -
重构代码:
Shift + F6
重命名变量/函数,自动更新所有引用。 -
本地历史: 右键文件选择
Local History → Show History
恢复误删代码。