PyCharm Keymap / Shortcut Key (快捷键大全)

PyCharm 为了适应来自于不同背景的开发者, 自定义了几套快捷键模式. 以下并不会列出所有的模式, 只列出了我自己最常用的两套.

  • Windows 下使用 Default 模式.

  • MacOS 下使用 MacOS 模式 (不是 MacOS System Shortcut 模式)

如果你要修改其中的一些快捷键, 我建议点击 Keymap 模板选择界面的齿轮, 并选择 Duplicate, 然后在此基础上修改. 免得覆盖了系统默认的快捷键模板.

以下表格来自于我先在我的 Google Sheet 中编辑 https://docs.google.com/spreadsheets/d/1-7blQUyf5BkYvxBIYDqZljm60IL2C-xitiffvk9otCY/edit?usp=sharing, 然后再用网页版工具 https://www.tablesgenerator.com/markdown_tables 将其转化为 Text Table.

Group

Description

Windows

MacOS

Linux

General

Copy (复制)

Ctrl + C

Cmd + C

General

Cut (剪切)

Ctrl + X

Cmd + X

General

Paste (粘贴)

Ctrl + V

Cmd + V

General

Undo (撤销)

Ctrl + Z

Cmd + Z

General

Redo (重做)

Ctrl + Y

Shift + Cmd + Y

General

Open (打开文件/文件夹)

Ctrl + O

General

Save (保存改动)

Ctrl + S

Cmd + S

General

Rename File (重命名文件名)

Shift + F6

Shift + F6

General

Quit (退出程序)

Alt + F4

Cmd + Q

General

Close Tab (关闭标签页)

Ctrl + W

Cmd + W

Edit

Find (搜索文本)

Ctrl + F

Ctrl + F

Edit

Find in Directory (在目录中的所有文件中搜索文本)

Shift + Ctrl + F

Shift + Ctrl + F

Edit

Replace (替换)

Ctrl + R

Ctrl + R

Edit

Replace in Directory (在目录中的所有文件中替换文本)

Shift + Ctrl + R

Shift + Ctrl + R

Edit

Find and Select Next (找到并选择 下一个 匹配)

Ctrl + G

Cmd + G

Edit

Find and Select Previous (找到并选择 上一个 匹配)

Shift + Ctrl + G

Shift + Cmd + G

Edit

Find and Select All (找到并选择全部)

Edit

Find and Add Select Next (找到并将 下一个 匹配添加到已选项)

Edit

Find and Multiple Edit (搜索到 所有 匹配后同时编辑)

Ctrl + F -> Alt + Enter

Cmd + F -> Alt + Enter

Line

Insert Line After (在 下面 另起一行, 光标跳到 下一行)

Shift + Enter

Shift + Enter

Line

Insert Line Before (在 上面 另起一行, 光标跳到 上一行)

Ctrl + Alt + Enter

Cmd + Alt + Enter

Line

Delete Line (删除该行)

Ctrl + D

Cmd + D

Duplicate Line (复制该行)

Ctrl + Alt + D

Cmd + BackSpace

Line

Indent / Unindent Line (增加/减少 该行缩进)

Tab / Shift + Tab

Tab / Shift + Tab

Line

Move Line Up/Down (移动该行)

Shift + Alt + Up/Down

Shift + Alt + Up/Down

Line

Join Lines (连接多行)

Ctrl + Shift + J

Ctrl + Shift + J

Line

Multiline Editing (多行同时编辑)

Alt + Click/Drag or Press Ctrl Twice + Up/Down to select lines

Cmd + Click/Drag or Press Alt Twice + Up/Down to select lines (连续按下 Alt 2 次并按住, 然后按上下选择. 或者 Shift + Alt + 鼠标拖曳)

Alt + Click/Drag or Press Ctrl Twice + Up/Down to select lines

Navigation

Previous/Next Tab (上/下 一个标签)

Alt + Left/Right or Ctrl + PageUp / Ctrl + PageDown (User Settings)

Shift + Cmd + [ / ] or Ctrl + PageUp / Ctrl + PageDown (User Settings)

Navigation

Previous/Next Cursor (上/下 一个游标所在)

Ctrl + Alt + Left/Right

Cmd + Alt + Left/Right

Navigation

Jump Between Bracket (在匹配的括号之间跳转)

Ctrl + Shift + M

Ctrl + M

Navigation

Go to Recent Files (显示最近打开的文件)

Cmd + E

Navigation

Go to Everything (全文搜索所有, 文件, 符号, 等…)

Ctrl + Shift + M

Double click Shift

Navigation

Go to File (根据文件名和目录名查找文件并跳转)

Cmd + Shift + O

Navigation

Go to Synbol (查找 类, 方法, 变量 名并跳转)

Cmd + Alt + O

Navigation

Go to Class (查找 类 并跳转)

Cmd + O

Navigation

Go to Action (查找 IDE 上的菜单)

Cmd + Shift + A

Navigation

Go to Line Number (定位到某行)

Ctrl + G

Cmd + L

Navigation

Show File Structure and Jump (打开临时的文件结构或目录窗口, 在 header 之间跳转)

Cmd + F12

Navigation

Show File in external File Explorer (将文件在外部文件浏览器中打开)

Cmd + Alt + F12

Menu

Settings (设定)

Ctrl + Alt + S

Cmd + ,

Menu

Pluggin (插件)

Menu

View Project

Cmd + 1

Menu

View Favorite

Cmd + 2

Menu

View Find

Cmd + 3

Menu

View Run

Cmd + 4

Menu

View Debug

Cmd + 5

Menu

View Problem

Cmd + 6

Menu

View Structure

Cmd + 7

Menu

View Services

Cmd + 8

Menu

View Git

Cmd + 9

IDE

Copy Name (复制文件/文件夹名)

Ctrl + C

Cmd + C

IDE

Copy Absolute Path (复制绝对路径)

Shift + Ctrl + C

Shift + Cmd + C

IDE

Open in Sublime Text (使用Sublime Text打开)

Ctrl + Shift + S

Ctrl + Shift + S

IDE

Open in Default Application (使用默认的App打开)

IDE

Run This Python File (运行当前编辑的Python脚本)

Ctrl + Shift + F10

Ctrl + Shift + R

IDE

Run Last File (运行上次运行的脚本)

Shift + F10

Ctrl + R

IDE

Select and Run (选择一个脚本运行)

Alt + Shift + F10 (2 is the current file)

Alt + Ctrl + R (2 is the current file)

IDE

Debug Last File (调试上次运行的脚本)

Shift + F9

Ctrl + D

IDE

Select and Debug (选择一个脚本调试)

Alt + Shift + F9 (2 is the current file)

Alt + Ctrl + D (2 is the current file)

IDE

Open Command Line/Terminal (打开命令行)

Alt + F12

Alt + F12

IDE

Fold/Unfold All Once (折叠/打开 代码一次)

Ctrl + +/-

Cmd + +/-

IDE

Fold/Unfold All Recursively (折叠/打开 全部代码)

Ctrl + Shift + +/-

Cmd + Shift + +/-

IDE

Bookmark Here (为某处添加书签)

F11

F3

IDE

Show ALl Bookmark (浏览所有的书签)

Shift + F11

Cmd + F3

Python

Comment/Uncomment (注释/取消注释)

Ctrl + /

Ctrl + /

Python

Navigate to Previous/Next Method (上/下一个函数)

Alt + Up/Down

Ctrl + Up/Down (Has to disable MacOS’s shortcut Mission Control and Application Window)

Python

Move Method/Class Up/Down (移动整个函数和类的位置)

Ctrl + Shift +

Shift + Cmd + Up/Down

Python

Find Usage (在项目中查找用例)

Alt + F7

Alt + F7

Python

Find Usage in File (在本文件中查找用例)

Ctrl + F7

Cmd + F7

Python

Highlight Usage in File (高亮本文件中的所有用例)

Shift + Ctrl + F7

Shift + Cmd + F7

Python

Go to Declaration (到第一次的声明处)

Ctrl + B

Cmd + B

Python

Go to Implementation (到实现处, 可能有多个)

Ctrl + Alt + B

Cmd + Alt + B

Python

View Definition (快速查看定义, 需要选中 类, 方法, 变量名)

Ctrl + Shift + I

Alt + Space

Python

View Document (快速查看文档, 需要选中 类, 方法, 变量名)

Ctrl + Q

F1

Python

View Parameters (快速查看参数信息, 游标要在括号内)

Cmd + P

Python

Show Type of Selected Variable (查看选中目标的类型信息)

Ctrl + Shift + P

Python

Pep8 Reformat (Pep8风格化代码)

Ctrl + Alt + L

Cmd + Alt + L

Python

Optimize Import (自动整理Import)

Ctrl + Alt + O

Ctrl + Alt + O

Python

Rename Variable (重命名变量)

Shift + F6

Shift + F6

Server Dev

Run Bash (使用Bash运行, 需要自定义 External Tool)

Shift + `

Shift + `

Server Dev

Run Bash Remotely (使用 Bash 在远程服务器上运行, 需要定义 Remote SSH External Tool)

Alt + `

Server Dev

Browser Remote Host (打开服务器的文件浏览器)

Alt + B

Server Dev

Upload to Remote (将本地文件全部上传至服务器)

Shift + Alt + Cmd + X