Article directory
overview
IDEA has many shortcut keys that can help you perform common tasks faster, such as navigating, searching, editing, compiling and debugging code, etc. Use these shortcut keys well, and the code writing will fly.
Manage shortcuts
Open Settings -> Keymap to open the shortcut key management list
Win version shortcut key
Ctrl shortcut key
hot key | illustrate | commonly used |
---|---|---|
Ctrl + F | Do a text search in the current file | √ |
Ctrl + R | Perform text replacement in the current file | √ |
Ctrl + Z | revoke | √ |
Ctrl + Y | Delete the line where the cursor is located or delete the selected line | √ |
Ctrl + X | Cut the line where the cursor is located or cut the selection | √ |
Ctrl + C | Copy the line where the cursor is located or copy the selection | |
Ctrl + D | Copy the line where the cursor is located or copy the selected content, and insert the copied content below the cursor position | √ |
Ctrl + W | Select blocks of code incrementally. The word or paragraph where the cursor is located can be selected, and continuous pressing will expand the selected range on the basis of the original selection | √ |
Ctrl + E | Display a list of recently opened file records | √ |
Ctrl + N | Find a class file based on the entered class name | √ |
Ctrl + G | Jump to the specified line in the current file | √ |
Ctrl + J | Insert custom dynamic code templates | |
Ctrl + P | Method parameter prompt display | √ |
Ctrl + Q | On the variable/class name/method name where the cursor is located (you can also press it when the prompt is added), display the content of the document | |
Ctrl + U | Go to the method/interface definition of the parent class of the method currently under the cursor | |
Ctrl + B | Enter the interface of the method/variable where the cursor is located or define it, equivalent to Ctrl + left click | |
Ctrl + K | Version control submission project, this project needs to be added to version control to be available | |
Ctrl + T | Version control update project, this project needs to be added to version control to be available | |
Ctrl + H | Show the current class hierarchy | √ |
Ctrl + O | Choose an overridable method | |
Ctrl + I | Choose an inheritable method | |
Ctrl + + | expand code | |
Ctrl + - | fold code | |
Ctrl + / | Note the line of code where the cursor is located, and different comment symbols will be used according to the current file type (required) | |
Ctrl + [ | Move the cursor to the beginning of the curly braces of the current code | |
Ctrl + ] | Move the cursor to the end of the curly braces of the current code | |
Ctrl + F1 | Display an error message at the error code where the cursor is located | |
Ctrl + F3 | Jump to the next quoted position of the selected word | |
Ctrl + F4 | close the currently edited file | |
Ctrl + F8 | In Debug mode, set the current behavior breakpoint of the cursor, and remove the breakpoint if it is already a breakpoint | |
Ctrl + F9 | Execute the Make Project operation | |
Ctrl + F11 | Select file/folder, set/unbookmark using mnemonic | |
Ctrl + F12 | Pop up the current file structure layer, you can directly input on the pop-up layer to filter | √ |
Ctrl + Tab | Editing window switching, if you press delete again during the switching process, the corresponding selected window will be closed | √ |
Ctrl + Enter | smart row divider | |
Ctrl + End | jump to end of file | |
Ctrl + Home | jump to header | |
Ctrl + Space | Basic code completion, which is occupied by the input method on the Windows system by default, needs to be modified, it is recommended to modify it to Ctrl + comma | √ |
Ctrl + Delete | Delete the word or Chinese sentence behind the cursor | |
Ctrl + BackSpace | Delete the word or Chinese sentence in front of the cursor | |
Ctrl + 1,2,3…9 | Navigate to the bookmark position corresponding to the value | |
Ctrl + left click | On the open file title, pop up the file path | |
Ctrl + cursor positioning | Press Ctrl and don't release it, a summary of the class information where the cursor is located will be displayed | |
Ctrl + left arrow key | The cursor jumps to the left beginning position of the current word/Chinese sentence | |
Ctrl + right arrow key | The cursor jumps to the beginning of the right side of the current word/Chinese sentence | |
Ctrl + forward arrow key | Equivalent to the mouse wheel forward effect | |
Ctrl + back arrow key | Equivalent to mouse wheel backward effect |
Alt shortcut key
hot key | illustrate | commonly used |
---|---|---|
Alt + ` | 显示版本控制常用操作菜单弹出层 | |
Alt + Q | 弹出一个提示,显示当前类的声明 / 上下文信息 | √ |
Alt + F1 | 显示当前文件选择目标弹出层,弹出层中有很多目标可以进行选择 | |
Alt + F2 | 对于前面页面,显示各类浏览器打开目标选择弹出层 | |
Alt + F3 | 选中文本,逐个往下查找相同文本,并高亮显示 | |
Alt + F7 | 查找光标所在的方法 / 变量 / 类被调用的地方 | |
Alt + F8 | 在 Debug 的状态下,选中对象,弹出可输入计算表达式调试框,查看该输入内容的调试结果 | |
Alt + Home | 定位 / 显示到当前文件的 Navigation Bar | |
Alt + Enter | IntelliJ IDEA 根据光标所在问题,提供快速修复选择,光标放在的位置不同提示的结果也不同 | √ |
Alt + Insert | 代码自动生成,如生成对象的 set / get 方法,构造函数,toString() 等 | √ |
Alt + 左方向键 | 按左方向切换当前已打开的文件视图 | |
Alt + 右方向键 | 按右方向切换当前已打开的文件视图 | |
Alt + 前方向键 | 当前光标跳转到当前文件的前一个方法名位置 | |
Alt + 后方向键 | 当前光标跳转到当前文件的后一个方法名位置 | |
Alt + 1,2,3…9 | 显示对应数值的选项卡,其中 1 是 Project 用得最多 | |
Alt + 鼠标选择 | 列选择模式,按列选择 | √ |
Shift 快捷键
快捷键 | 说明 | 常用 |
---|---|---|
Shift + F1 | 如果有外部文档可以连接外部文档 | |
Shift + F2 | 跳转到上一个高亮错误 或 警告位置 | |
Shift + F3 | 在查找模式下,查找匹配上一个 | |
Shift + F4 | 对当前打开的文件,使用新Windows窗口打开,旧窗口保留 | |
Shift + F6 | 对文件 / 文件夹 重命名 | |
Shift + F7 | 在 Debug 模式下,智能步入。断点所在行上有多个方法调用,会弹出进入哪个方法 | |
Shift + F8 | 在 Debug 模式下,跳出,表现出来的效果跟 F9 一样 | |
Shift + F9 | 等效于点击工具栏的 Debug 按钮 | |
Shift + F10 | 等效于点击工具栏的 Run 按钮 | |
Shift + F11 | 弹出书签显示层 | |
Shift + Tab | 取消缩进 | |
Shift + ESC | 隐藏当前 或 最后一个激活的工具窗口 | |
Shift + End | 选中光标到当前行尾位置 | |
Shift + Home | 选中光标到当前行头位置 | |
Shift + Enter | 开始新一行。光标所在行下空出一行,光标定位到新行位置 | |
Shift + 左键单击 | 在打开的文件名上按此快捷键,可以关闭当前打开文件 | |
Shift + 滚轮前后滚动 | 当前文件的横向滚动轴滚动 |
Ctrl + Alt 快捷键
快捷键 | 说明 | 常用 |
---|---|---|
Ctrl + Alt + L | 格式化代码,可以对当前文件和整个包目录使用 | √ |
Ctrl + Alt + O | 优化导入的类,可以对当前文件和整个包目录使用 | √ |
Ctrl + Alt + I | 光标所在行 或 选中部分进行自动代码缩进,有点类似格式化 | |
Ctrl + Alt + T | 对选中的代码弹出环绕选项弹出层 | √ |
Ctrl + Alt + J | 弹出模板选择窗口,讲选定的代码加入动态模板中 | |
Ctrl + Alt + H | 调用层次 | |
Ctrl + Alt + B | 在某个调用的方法名上使用会跳到具体的实现处,可以跳过接 | |
Ctrl + Alt + C | 将内容提取成常量 | √ |
Ctrl + Alt + M | 提取方法,将选中的代码提取到方法里 | √ |
Ctrl + Alt + V | 快速引进变量 | √ |
Ctrl + Alt + Y | 同步、刷新 | |
Ctrl + Alt + S | 打开 IntelliJ IDEA 系统设置 | |
Ctrl + Alt + F7 | 显示使用的地方。寻找被该类或是变量被调用的地方,用弹出框的方式找出来 | |
Ctrl + Alt + F11 | 切换全屏模式 | |
Ctrl + Alt + Enter | 光标所在行上空出一行,光标定位到新行 | √ |
Ctrl + Alt + Home | 弹出跟当前文件有关联的文件弹出层 | |
Ctrl + Alt + Space | 类名自动完成 | |
Ctrl + Alt + 左方向键 | 退回到上一个操作的地方 | √ |
Ctrl + Alt + 右方向键 | 前进到上一个操作的地方 | √ |
Ctrl + Alt + 前方向键 | 在查找模式下,跳到上个查找的文件 | |
Ctrl + Alt + 后方向键 | 在查找模式下,跳到下个查找的文件 |
Ctrl + Shift 快捷键
快捷键 | 说明 | 常用 |
---|---|---|
Ctrl + Shift + F | 根据输入内容查找整个项目 或 指定目录内文件 | √ |
Ctrl + Shift + R | 根据输入内容替换对应内容,范围为整个项目 或 指定目录内文 | √ |
Ctrl + Shift + J | 自动将下一行合并到当前行末尾 | √ |
Ctrl + Shift + Z | 取消撤销 | √ |
Ctrl + Shift + W | 递进式取消选择代码块。可选中光标所在的单词或段落,连续按会在原有选中的基础上再扩展取消选中范围 | √ |
Ctrl + Shift + N | 通过文件名定位 / 打开文件 / 目录,打开目录需要在输入的内容后面多加一个正斜杠 | √ |
Ctrl + Shift + U | 对选中的代码进行大 / 小写轮流转换 | √ |
Ctrl + Shift + T | 对当前类生成单元测试类,如果已经存在的单元测试类则可以进行选择 | |
Ctrl + Shift + C | 复制当前文件磁盘路径到剪贴板 | |
Ctrl + Shift + V | 弹出缓存的最近拷贝的内容管理器弹出层 | |
Ctrl + Shift + E | 显示最近修改的文件列表的弹出层 | |
Ctrl + Shift + H | 显示方法层次结构 | |
Ctrl + Shift + B | 跳转到类型声明处 | |
Ctrl + Shift + I | 快速查看光标所在的方法 或 类的定义 | |
Ctrl + Shift + A | 查找动作 / 设置 | |
Ctrl + Shift + / | 代码块注释 | √ |
Ctrl + Shift + [ | 选中从光标所在位置到它的顶部中括号位置 | |
Ctrl + Shift + ] | 选中从光标所在位置到它的底部中括号位置 | |
Ctrl + Shift + + | 展开所有代码 | |
Ctrl + Shift + - | 折叠所有代码 | |
Ctrl + Shift + F7 | 高亮显示所有该选中文本,按Esc高亮消失 | |
Ctrl + Shift + F8 | 在 Debug 模式下,指定断点进入条件 | |
Ctrl + Shift + F9 | 编译选中的文件 / 包 / Module | |
Ctrl + Shift + F10 | 运行 | √ |
Ctrl + Shift + F12 | 编辑器最大化 | |
Ctrl + Shift + Space | 智能代码提示 | |
Ctrl + Shift + Enter | 自动结束代码,行末自动添加分号 | √ |
Ctrl + Shift + Backspace | 退回到上次修改的地方 | |
Ctrl + Shift + 1,2,3…9 | 快速添加指定数值的书签 | |
Ctrl + Shift + 左方向键 | 在代码文件上,光标跳转到当前单词 / 中文句的左侧开头位置,同时选中该单词 / 中文句 | |
Ctrl + Shift + 右方向键 | 在代码文件上,光标跳转到当前单词 / 中文句的右侧开头位置,同时选中该单词 / 中文句 | |
Ctrl + Shift + 左方向键 | 在光标焦点是在工具选项卡上,缩小选项卡区域 | |
Ctrl + Shift + 右方向键 | 在光标焦点是在工具选项卡上,扩大选项卡区域 | |
Ctrl + Shift + 前方向键 | 光标放在方法名上,将方法移动到上一个方法前面,调整方法排序 | |
Ctrl + Shift + 后方向键 | 光标放在方法名上,将方法移动到下一个方法前面,调整方法排序 |
Alt + Shift 快捷键
快捷键 | 说明 | 常用 |
---|---|---|
Alt + Shift + N | 选择 / 添加 task | |
Alt + Shift + F | 显示添加到收藏夹弹出层 | |
Alt + Shift + C | 查看最近操作项目的变化情况列表 | |
Alt + Shift + F | 添加到收藏夹 | |
Alt + Shift + I | 查看项目当前文件 | |
Alt + Shift + F7 | 在 Debug 模式下,下一步,进入当前方法体内,如果方法体还有方法,则会进入该内嵌的方法中,依此循环进入 | |
Alt + Shift + F9 | 弹出 Debug 的可选择菜单 | |
Alt + Shift + F10 | 弹出 Run 的可选择菜单 | |
Alt + Shift + 左键双击 | 选择被双击的单词 / 中文句,按住不放,可以同时选择其他单词 / 中文句 | |
Alt + Shift + 前方向键 | 移动光标所在行向上移动 | |
Alt + Shift + 后方向键 | 移动光标所在行向下移动 |
Ctrl + Shift + Alt 快捷键
快捷键 | 说明 | 常用 |
---|---|---|
Ctrl + Shift + Alt + V | 无格式黏贴 | |
Ctrl + Shift + Alt + N | 前往指定的变量 / 方法 | |
Ctrl + Shift + Alt + S | 打开当前项目设置 | |
Ctrl + Shift + Alt + C | 复制参考信息 |
其他快捷键
快捷键 | 说明 | 常用 |
---|---|---|
F2 | 跳转到下一个高亮错误 或 警告位置 | √ |
F3 | 在查找模式下,定位到下一个匹配处 | |
F4 | 编辑源 | |
F7 | 在 Debug 模式下,进入下一步,如果当前行断点是一个方法,则进入当前方法体内,如果该方法体还有方法,则不会进入该内嵌的方法中 | |
F8 | 在 Debug 模式下,进入下一步,如果当前行断点是一个方法,则不进入当前方法体内 | |
F9 | 在 Debug 模式下,恢复程序运行,但是如果该断点下面代码还有断点则停在下一个断点上 | |
F11 | 添加书签 | |
F12 | 回到前一个工具窗口 | |
Tab | 缩进 | |
ESC | 从工具窗口进入代码文件窗口 | |
连按两次Shift | 弹出 Search Everywhere 弹出层 |
Mac版快捷键
Mac 键盘符号和修饰键说明
按键 | 说明 | 常用 |
---|---|---|
⌘ | Command | |
⇧ | Shift | |
⌥ | Option | |
⌃ | Control | |
↩︎ | Return/Enter | |
⌫ | Delete | |
⌦ | 向前删除键(Fn+Delete) | |
↑ | 上箭头 | |
↓ | 下箭头 | |
← | 左箭头 | |
→ | 右箭头 | |
⇞ | Page Up(Fn+↑) | |
⇟ | Page Down(Fn+↓) | |
Home | Fn + ← | |
End | Fn + ← | |
⇥ | 右制表符(Tab 键) | |
⇤ | 左制表符(Shift+Tab) | |
⎋ | Escape (Esc) |
代码编辑
快捷键 | 说明 | 常用 |
---|---|---|
⌃Space | 基本的代码补全(补全任何类、方法、变量) | |
⌃⇧Space | 智能代码补全(过滤器方法列表和变量的预期类型) | |
⌘⇧↩ | 自动结束代码,行末自动添加分号 | |
⌘P | 显示方法的参数信息 | |
⌃J, Mid. button click | 快速查看文档 | |
⇧F1 | 查看外部文档(在某些代码上会触发打开浏览器显示相关文档) | |
⌘+鼠标放在代码上 | 显示代码简要信息 | |
⌘F1 | 在错误或警告处显示具体描述信息 | |
⌘N, ⌃↩, ⌃N | 生成代码(getter、setter、构造函数、hashCode/equals,toString) | |
⌃O | 覆盖方法(重写父类方法) | |
⌃I | 实现方法(实现接口中的方法) | |
⌘⌥T | 包围代码(使用 if…else, try…catch, for, synchronized 等包围 选中的代码) | |
⌘/ | 注释/取消注释与行注释 | |
⌘⌥/ | 注释/取消注释与块注释 | |
⌥↑ | 连续选中代码块 | |
⌥↓ | 减少当前选中的代码块 | |
⌃⇧Q | 显示上下文信息 | |
⌥↩ | 显示意向动作和快速修复代码 | |
⌘⌥L | 格式化代码 | |
⌃⌥O | 优化 import | |
⌃⌥I | 自动缩进线 | |
⇥ / ⇧⇥ | 缩进代码 / 反缩进代码 | |
⌘X | 剪切当前行或选定的块到剪贴板 | |
⌘C | 复制当前行或选定的块到剪贴板 | |
⌘V | 从剪贴板粘贴 | |
⌘⇧V | 从最近的缓冲区粘贴 | |
⌘D | 复制当前行或选定的块 | |
⌘⌫ | 删除当前行或选定的块的行 | |
⌃⇧J | 智能的将代码拼接成一行 | |
⌘↩ | 智能的拆分拼接的行 | |
⇧↩ | 开始新的一行 | |
⌘⇧U | 大小写切换 | |
⌘⇧] / ⌘⇧[ | 选择直到代码块结束/开始 | |
⌥⌦ | 删除到单词的末尾(⌦ 键为 Fn+Delete) | |
⌥⌫ | 删除到单词的开 | |
⌘+ / ⌘- | 展开 / 折叠代码块 | |
⌘⇧+ | 展开所以代码块 | |
⌘⇧- | 折叠所有代码块 | |
⌘W | 关闭活动的编辑器选项卡 |
查询/替换
快捷键 | 说明 | 常用 |
---|---|---|
Double ⇧ | 查询任何东西 | |
⌘F | 文件内查找 | |
⌘G | 查找模式下,向下查找 | |
⌘⇧G | 查找模式下,向上查找 | |
⌘R | 文件内替换 | |
⌘⇧F | 全局查找(根据路径) | |
⌘⇧R | 全局替换(根据路径) | |
⌘⇧S | 查询结构(Ultimate Edition 版专用,需要在 Keymap 中设置) | |
⌘⇧M | 替换结构(Ultimate Edition 版专用,需要在 Keymap 中设置) |
使用查询
快捷键 | 说明 | 常用 |
---|---|---|
⌥F7 / ⌘F7 | 在文件中查找用法 / 在类中查找用法 | |
⌘⇧F7 | 在文件中突出显示的用法 | |
⌘⌥F7 | 显示用法 |
编译和运行
快捷键 | 说明 | 常用 |
---|---|---|
⌘F9 | 编译 Project | |
⌘⇧F9 | 编译选择的文件、包或模块 | |
⌃⌥R | 弹出 Run 的可选择菜单 | |
⌃⌥D | 弹出 Debug 的可选择菜单 | |
⌃R | 运行 | |
⌃D | 调试 | |
⌃⇧R, ⌃⇧D | 从编辑器运行上下文环境配置 |
调试
快捷键 | 说明 | 常用 |
---|---|---|
F8 | 进入下一步,如果当前行断点是一个方法,则不进入当前方法体内 | |
F7 | 进入下一步,如果当前行断点是一个方法,则进入当前方法体内,如果该方法体还有方法,则不会进入该内嵌的方法中 | |
⇧F7 | 智能步入,断点所在行上有多个方法调用,会弹出进入哪个方 | |
⇧F8 | 跳出 | |
⌥F9 | 运行到光标处,如果光标前有其他断点会进入到该断点 | |
⌥F8 | 计算表达式(可以更改变量值使其生效) | |
⌘⌥R | 恢复程序运行,如果该断点下面代码还有断点则停在下一个断点上 | |
⌘F8 | 切换断点(若光标当前行有断点则取消断点,没有则加上断点) | |
⌘⇧F8 | 查看断点信息 |
导航
快捷键 | 说明 | 常用 |
---|---|---|
⌘O | 查找类文件 | |
⌘⇧O | 查找所有类型文件、打开文件、打开目录,打开目录需要在输入的内容前面或后面加一个反斜杠/ | |
⌘⌥O | 前往指定的变量 / 方法 | |
⌃← / ⌃→ | 左右切换打开的编辑 tab 页 | |
F12 | 返回到前一个工具窗口 | |
⎋ | 从工具窗口进入代码文件窗口 | |
⇧⎋ | 隐藏当前或最后一个活动的窗口,且光标进入代码文件窗口 | |
⌘⇧F4 | 关闭活动 run/messages/find/… tab | |
⌘L | 在当前文件跳转到某一行的指定处 | |
⌘E | 显示最近打开的文件记录列表 | |
⌘⌥← / ⌘⌥→ | 退回 / 前进到上一个操作的地方 | |
⌘⇧⌫ | 跳转到最后一个编辑的地方 | |
⌥F1 | 显示当前文件选择目标弹出层,弹出层中有很多目标可以进行选择(如在 代码编辑窗口可以选择显示该文件的 Finder) | |
⌘B / ⌘ | 鼠标点击 进入光标所在的方法/变量的接口或是定义 | |
⌘⌥B | 跳转到实现处,在某个调用的方法名上使用会跳到具体的实现处,可以跳过接口 | |
⌥ Space, ⌘Y | 快速打开光标所在方法、类的定义 | |
⌃⇧B | 跳转到类型声明处 | |
⌘U | 前往当前光标所在方法的父类的方法 / 接口定义 | |
⌃↓ / ⌃↑ | 当前光标跳转到当前文件的前一个/后一个方法名位置 | |
⌘] / ⌘[ | 移动光标到当前所在代码的花括号开始/结束位置 | |
⌘F12 | 弹出当前文件结构层,可以在弹出的层上直接输入进行筛选(可用于搜索类中的方法) | |
⌃H | 显示当前类的层次结构 | |
⌘⇧H | 显示方法层次结构 | |
⌃⌥H | 显示调用层次结构 | |
F2 / ⇧F2 | 跳转到下一个/上一个突出错误或警告的位置 | |
F4 / ⌘↓ | 编辑/查看代码源 | |
⌥ Home | 显示到当前文件的导航条 | |
F3 | 选中文件/文件夹/代码行,添加/取消书签 | |
⌥F3 | 选中文件/文件夹/代码行,使用助记符添加/取消书签 | |
⌃0…⌃9 | 定位到对应数值的书签位置 | |
⌘F3 | 显示所有书签 |
重构
快捷键 | 说明 | 常用 |
---|---|---|
F5 | 复制文件到指定目录 | |
F6 | Move the file to the specified directory | |
⌘⌫ | On the file to delete the file safely, a confirmation box pops up | |
⇧F6 | rename file | |
⌘F6 | change signature | |
⌘⌥N | consistency | |
⌘⌥M | Extract selected code as a method | |
⌘⌥V | extract variables | |
⌘⌥F | extract fields | |
⌘⌥C | extract constant | |
⌘⌥P | Extract parameters |
version control / local history
hot key | illustrate | commonly used |
---|---|---|
⌘K | Commit code to version controller | |
⌘T | Update code from version controller | |
⌥⇧C | View recent change history | |
⌃C | Quick pop-up version controller operation panel |
Dynamic code template
hot key | illustrate | commonly used |
---|---|---|
⌘⌥J | A template selection window will pop up, wrap the selected code with a dynamic template | |
⌘J | Insert custom dynamic code templates |
universal
hot key | illustrate | commonly used |
---|---|---|
⌘1…⌘9 | Open the corresponding numbered tool window | |
⌘S | save all | |
⌘⌥Y | sync, refresh | |
⌃⌘F | Toggle full screen mode | |
⌘⇧F12 | Toggle maximized editor | |
⌥⇧F | add to favorites | |
⌥⇧I | Check the current file with the current configuration file | |
§⌃, ⌃` | Quickly switch the current scheme (switch theme, code style, etc.) | |
⌘, | Open IDEA system settings | |
⌘; | Open the project structure dialog | |
⇧⌘A | Find action (you can set related options) | |
⌃⇥ | Switch between editing window tabs and tool windows (if you press delete during the switching process, the corresponding selected window will be closed) |
Templates/Custom Code Templates
IDEA opens the code template settings:File -> settings -> editor -> Live templates
generate main function
psvm
Enter or in a class main
, IDEA will automatically generate the main method main;
Quickly generate print statements
editor inputsout
Quickly generate plain for loops
editor inputfori / itar
Quickly generate enhanced for loops
editor inputiter
custom template
Enter the live template interface, enter
Custom code template group
Custom Code Templates
add template
Write shortcut key instructions and code content