PyCharm 常用配置
Last updated
Last updated
keywords: PyCharm Config
Appearance & Behavior | Appearance -> Font -> 推荐 JetBrains Mono Medium (Size 根据分辨率调整)
Editor | Font -> 推荐 Source Code Pro (推荐适当调大字体, 调小行间距)
Editor | General | Appearance -> Show whitespaces
Editor | General -> On Save (全部勾选)
Editor | General | Code Folding -> Imports (取消勾选)
Tools | Python Integrated Tools -> Docstring format -> Google
Keymap
先安装插件:Plugins -> Marketplace -> Eclipse Keymap
Windows 选 Eclipse, 非 Eclipse (macOS)
常用快捷键
标注
*
的表示继承自 Eclipse Keymap, 不需要修改;
行上移 (替代"语句上移")
Main Menu/Code/Move Line Up
command + up
Alt + ↑
行下移 (替代"语句下移")
Main Menu/Code/Move Line Down
command + down
Alt + ↓
跳转到源代码 (同跳转定义)
Main Menu/View/Jump to Source
command + click
Ctrl + Click
代码格式化 (与"文件中查找"互换)
Main Menu/Code/Code Formatting Actions/Reformat Code
shift + command + F
Alt + Shift + F
运行 (替代"跳转文件")
Main Menu/Run/Run
shift + control + R
Shift + Ctrl + R
跳转文件
Main Menu/Navigate/Goto by Name Actions/Go to File...
shift + command + J
Alt + Shift + J
关闭当前文件
Main Menu/Window/Editor Tabs/Editor Close Actions/Close Tab
control + W
Ctrl + W
*文件中查找
Main Menu/Edit/Find/Find in Files...
control + H
Ctrl + H
*关闭当前Tab
Main Menu/Window/Active Tool Window/Close Active Tab
control + W
Ctrl + W
*重命名
Main Menu/Refactor/Rename...
option + command + R
Alt + Shift + R
*复制行
Editor Actions/Duplicate Entire Lines
control + command + down
Ctrl + Alt + ↓
*删除行
Editor Actions/Delete Line
command + D
Ctrl + D
*跳转定义
Main Menu/Navigate/Go to Declaration or Usages
command + click
Ctrl + Click
*大小写互转
Editor Actions/Toggle Case
shift + command + U
Ctrl + Shift + U
*行注释
Main Menu/Code/Comment Actions/Comment with Line Comment
command + /
Ctrl + /
*开始新行
Editor Actions/Start New Line
shift + enter
Shift + Enter
Editor | Inspections -> Code is incompatible with specific Python versions
Editor | File and Code Templates -> Python Script
更多内置变量详见:File template variables | PyCharm
Build, Execution, Deployment | Console | Python Console
Editor | Live Templates -> Python
将 super()
的自动补全修改为 Python3 模式
Dracula Theme(推荐)
问题描述:在全屏模式下打开新项目,默认在当前窗口的 Tab 页打开,而不是新窗口;这个问题不是因为 PyCharm 导致的,而是 Mac 的设置;
解决方法:系统偏好设置 -> 通用 -> 首选以标签页方式打开文稿
改为 永不
;