Intellij Idea快捷键(jetbrains全家桶通用)

2021-06-06 约 3319 字 预计阅读 7 分钟

Intellij Idea快捷键,包含jetbrains家族的通用快捷键,除了java的idea,python的pycharm和web前端的webstorm,go的GoLand等等这些都是常用的,这些快捷键几乎通用,所以把idea的快捷键搞熟了还是有很大收益的.

1. 官方Keymap

1.1. Windows Linux

image-20210315190246655

1.2. macOS

image-20210315190350195

2. Important❤️

Key Description Rate⭐
ctrl-w 进一步展开一段代码,比如闭合标签,方法,类 ⭐⭐⭐⭐⭐
ctrl-shift-w 相反的操作 ⭐⭐⭐⭐⭐
ctrl-shift-space 智能补全 ⭐⭐⭐⭐⭐
alt-enter quick-fix,import etc ⭐⭐⭐⭐⭐
alt-insert 自动生成代码,构造函数,getter,setter,override等等 ⭐⭐⭐⭐⭐
shfit-F6 重命名 ⭐⭐⭐⭐⭐
Ctrl-P 参数信息 ⭐⭐⭐⭐⭐

3. General❤️

Key Description Rate⭐
ctrl-shift-a 查找action ⭐⭐⭐⭐⭐
shift x 2 查找所有 ⭐⭐⭐⭐⭐
ctrl x 2 run anything ⭐⭐⭐⭐⭐
shift-alt-c 最近的改变 ⭐⭐⭐⭐
⭐⭐⭐⭐⭐
⭐⭐⭐⭐

4. Edit

Key Description Rate⭐
alt-shift-up/down 向上/下移动一行 ⭐⭐⭐⭐⭐
ctrl-y 删除一行 ⭐⭐⭐⭐⭐
ctrl-d Duplicate ⭐⭐⭐⭐
shift-enter 下面增加一行(不管光标在何处) ⭐⭐⭐⭐
ctrl-alt-enter 上面增加一行 ⭐⭐⭐⭐⭐
ctrl-shift-insert 打开剪贴板并插入 ⭐⭐⭐⭐

5. Navigation❤️

Key Description Rate⭐
ctrl-n 打开类 ⭐⭐⭐⭐⭐
ctrl-shift-n 打开文件 ⭐⭐⭐⭐⭐
ctrl-e 最近编辑过的文件 ⭐⭐⭐⭐⭐
ctrl-shift-e 最近的编辑的地方 带窗口
ctrl-alt-shift up/down 上一个/下一个改变(在git提交以后) ⭐⭐⭐⭐⭐
ctrl-F12 文件结构 ⭐⭐⭐⭐⭐
ctrl-G Goto Line ⭐⭐⭐⭐
ctrl-shift-backspace 上次编辑的地方 ⭐⭐⭐⭐
ctrl-shift-alt-n 查找和跳转symbol
alt-F1 在所有窗口里显示当前文件
Ctrl-` Switch
Key Description Rate⭐
alt-j 选择下一个(类似vscode的ctrl-d) ⭐⭐⭐⭐⭐
shift-alt-j 取消上一个选择 ⭐⭐⭐⭐
ctrl-shift-alt-j 一次性选择所有 ⭐⭐⭐⭐
F3 下一个 ⭐⭐⭐⭐
Shift-F3 上一个 ⭐⭐⭐⭐
ctrl-shift-F 全局搜索 ⭐⭐⭐⭐⭐
Ctrl-F3 下一个(不选择)

7. Coding❤️

Key Description Rate⭐
Ctrl-alt-L 格式化代码 再加上shift弹出格式化对话框 ⭐⭐⭐⭐⭐
ctrl-alt-o 优化import ⭐⭐⭐⭐⭐
F2 下一个错误 ⭐⭐⭐⭐
Shift-F2 上一个错误 ⭐⭐⭐⭐
Ctrl-shift-B Goto Type Declaration 类型定义 ⭐⭐⭐⭐
Ctrl-B Goto Declaration or Usages 声明或者使用 ⭐⭐⭐⭐
Ctrl-U Goto super method 方法的父类实现
Ctrl-Alt-B Goto implements
Ctrl-Shift-T Goto Tesing(可以创建新的测试)
Alt-F7 查找usages
Alt-up/down 跳转上一个/下一个method
ctrl-F7 当前文件的usage
ctrl-shift-F7 高亮当前文件所有的usage
ctrl-alt-F7 查找所有的usage,弹出跳转窗口
F4 编辑源文件,类,方法等等,相当于ctrl-鼠标点击
ctrl-Q 快速查看文档
Ctrl-shift-[ / ] 选择代码直到代码块结束 向上/向下 ⭐⭐⭐⭐
ctrl-shift-m 类似vim的%, 在结对的括号等之间跳转

8. Refactor

Key Description Rate⭐
Shift-F6 重命名 ⭐⭐⭐⭐⭐
Ctrl-Alt-M 提取方法 ⭐⭐⭐⭐
Ctrl-Alt-T 语句包裹,比如try,if等等 ⭐⭐⭐⭐
ctrl-alt-v 提取变量将一段代码表达式赋值为一个变量 ⭐⭐⭐⭐
ctrl-alt-c 提取常量 ⭐⭐⭐⭐
ctrl-alt-f 提取field ⭐⭐⭐
ctrl-alt-p 提取参数 ⭐⭐⭐
ctrl-alt-n inline variables,内联函数,将方法展开到此处,移除原来的方法 ⭐⭐⭐
ctrl-alt-shift-T refactor this(都记不住的话,记住这个就行) ⭐⭐⭐⭐

9. Bookmark❤️

Key Description Rate⭐
ctrl-shfit-[0-9] 添加bookmark用数字开标记bookmark ⭐⭐⭐⭐⭐
ctrl+[0-9] 用数字标记来跳转 ⭐⭐⭐⭐⭐
F11 添加bookmark(没有任何标记) ⭐⭐⭐⭐
Shift+F11 导航所有bookmark ⭐⭐⭐⭐⭐
ctrl+F11 添加bookmark,打开一个面板可以用字母等等开标记 ⭐⭐⭐⭐
Alt-shift-F 添加到Favorites

10. Window panel

Key Description Rate⭐
alt-[0-9] 各个tools的面板 ⭐⭐⭐⭐⭐
alt-1 project
alt-2 favorites
alt-3 find
alt-4 run
alt-5 debug
alt-6 problems
alt-7 文件的structure ⭐⭐⭐⭐⭐
alt-8 services
alt-9 git
alt-0 commit
alt-F12 terminal
ctrl-shift-F12 隐藏所有面板

11. Run Debug

Key Description Rate⭐
Shift-F9 debug 运行目前配置好的那个debug ⭐⭐⭐⭐⭐
alt-shift-F9 Debug 在当前文件,可能会弹出提示符
Shift-F10 Run 运行正在使用的那个RUN的配置
alt-shift-F10 Run 在当前文件弹出提示,来运行RUN
ctrl-F8 断点
ctrl-shift-f8 查看所有断点
alt-F8 计算表达式
alt-F9 执行到光标处

12. SCM

Key Description Rate⭐
Alt-` vcs菜单 ⭐⭐⭐⭐⭐
ctrl-shift-` branch
ctrl-k commit
ctrl-shift-k push

13. Folding

Key Description Rate⭐
Ctrl-+ 展开 ⭐⭐⭐⭐⭐
Ctrl- - 折叠
Ctrl-Shift-+ 展开所有
Ctrl-Shift– 折叠所有
Ctrl-Alt-+ 递归展开
Ctrl-Alt– 递归折叠
Ctrl-Shift-. 折叠代码块

14. Build

Key Description Rate⭐
Ctrl-F9 build项目 ⭐⭐⭐⭐⭐

15. 结合IdeaVim❤️

安装IdeaVim以后做了很多定制,解决冲突问题

一些Idea在vim模式下重新映射了

首先最主要的是映射一个快捷键,来开关vim emulator,可以在设置的keymap里找,也可以直接find action, 知道vim emulator,然后按alt-enter来设置一个快捷键

关于如何映射快捷键,需要先打开track Action ids

image-20210317090633044

这样在执行快捷键或者命令的时候,右下角会有一个提示,可以点击copy action id,然后到.ideavimrc里进行键盘映射

image-20210317090803177

15.1. IDEA的快捷键被重新映射的

Ctrl+ C, L, S, D, Z, 在vim和idea里也没有重要的用处,可以拿来做重映射

Key Desc Rate
Ctrl-z 原ctrl-w,扩展选择代码块
leader u 原ctrl-u, go to super method
Leader j 原ctrl-j, live template
leader o 原ctrl-o, override method
leader i 原ctrl-i,implement method
leader h 原Ctrl-h,Type hierarchy
leader b 原ctrl-b, goto declaration
g; 上一处编辑的地方(调用idea的action)
g, 下一处编辑的地方(调用idea的action)
Ctrl-o 一样还是back(调用idea的action)
Ctrl-i 一样是前进(调用idea的action)
Leader r rename(shift f6太远)
Ctrl-a easymotion的prefix

15.2. 我的ideavimrc

编辑的话可以action->vim action -> open ideavimrc

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
""" set leader -----------------------------
let mapleader = " "
let g:mapleader = " "

""" tab settings ---------------------------
set smarttab
set tabstop=4
set softtabstop=4
set shiftwidth=4
set shiftround

""" Searching -------------------------------
set hlsearch
set incsearch
set ignorecase
set smartcase

""" Common settings -------------------------
set showmode
set so=5
set incsearch
set nu

" command completion like zsh ---------------
" set wildmenu
" set wildmode=full

""" Split ----------------------------------
" noremap <Leader>h :<C-u>split<CR>
" noremap <Leader>v :<C-u>vsplit<CR>

""" Plugins  --------------------------------
set surround
set multiple-cursors
set commentary
set argtextobj
set easymotion
set textobj-entire
set ReplaceWithRegister


""" Use IdeaJoin ----------------------------
set ideajoin

""" Use IJ bookmark ------------------------
" set ideamarks

""" Plugin settings -------------------------
let g:argtextobj_pairs="[:],(:),<:>"
map <C-a> <Plug>(easymotion-prefix)



""" Disable arrowkeys ----------------------
noremap <Up> <Nop>
noremap <Down> <Nop>
noremap <Left> <Nop>
noremap <Right> <Nop>

""" Idea Actions ---------------------------
" Idea Ctrl-u
noremap <Leader>u :action GotoSuperMethod<CR>
" Idea Ctrl-o
noremap <Leader>o :action OverrideMethods<CR>
" live template
noremap <Leader>j :action InsertLiveTemplate<CR>
" git commit
noremap <Leader>k :action CheckinProject<CR>
" implement method
noremap <Leader>i :action ImplementMethods<CR>
" Type Hierarchy
noremap <Leader>h :action TypeHierarchy<CR>
" Go to Declaration
noremap <Leader>b :action GotoDeclaration<CR>
" commit history
noremap <Leader>m :action Vcs.ShowTabbedFileHistory<CR>
" extend selection
map <C-z> :action EditorSelectWord<CR>
" Jump to changes(试了一下暂时没有发现有问题)
" noremap g; :action JumpToLastChange<CR>
" noremap g, :action JumpToNextChange<CR>
" forward and back(试了一下暂时没有发现有问题)
" map <C-o> :action Back<CR>
" map <c-i> :action Forward<CR>
noremap <Leader>r :action RenameElement<CR>

15.3. plugins

15.3.1. easymotion

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
 Default Mapping |  <Plug> command       |
   -----------------------------------------------------------------
    <ll>f{char}    |  <Plug>(easymotion-f) |  mapped to fn
    <ll>F{char}    |  <Plug>(easymotion-F) |  mapped to Fn
    <ll>t{char}    |  <Plug>(easymotion-t) |  mapped to tn
    <ll>T{char}    |  <Plug>(easymotion-T) |  mapped to Tn

    <ll>w          |  <Plug>(easymotion-w) |
    <ll>W          |  <Plug>(easymotion-W) |
    <ll>b          |  <Plug>(easymotion-b) |
    <ll>B          |  <Plug>(easymotion-B) |
    <ll>e          |  <Plug>(easymotion-e) |
    <ll>E          |  <Plug>(easymotion-E) |
    <ll>ge         |  <Plug>(easymotion-ge |
    <ll>gE         |  <Plug>(easymotion-gE |
    <ll>j          |  <Plug>(easymotion-j) |
    <ll>k          |  <Plug>(easymotion-k) |
    <ll>n          |  <Plug>(easymotion-n) |
    <ll>N          |  <Plug>(easymotion-N) |
    <ll>s          |  <Plug>(easymotion-s) |  mapped to sn


    More <Plug> Mapping Table         |  Note
    ----------------------------------|----------------------
    <Plug>(easymotion-bd-f)           |
    <Plug>(easymotion-bd-t)           |  mapped to bd-tn
    <Plug>(easymotion-bd-w)           |
    <Plug>(easymotion-bd-W)           |
    <Plug>(easymotion-bd-e)           |
    <Plug>(easymotion-bd-E)           |
    <Plug>(easymotion-bd-jk)          |
    <Plug>(easymotion-bd-n)           |
    <Plug>(easymotion-jumptoanywhere) |

    <Plug>(easymotion-repeat)         |  UNSUPPORTED
    <Plug>(easymotion-next)           |  UNSUPPORTED
    <Plug>(easymotion-prev)           |  UNSUPPORTED

    <Plug>(easymotion-sol-j)          |
    <Plug>(easymotion-sol-k)          |
    <Plug>(easymotion-eol-j)          |
    <Plug>(easymotion-eol-k)          |
    <Plug>(easymotion-iskeyword-w)    |
    <Plug>(easymotion-iskeyword-b)    |
    <Plug>(easymotion-iskeyword-bd-w) |
    <Plug>(easymotion-iskeyword-e)    |
    <Plug>(easymotion-iskeyword-ge)   |
    <Plug>(easymotion-iskeyword-bd-e) |
    <Plug>(easymotion-vim-n)          |
    <Plug>(easymotion-vim-N)          |

    Within Line Motion                | Note 
    ----------------------------------|---------------------------------
    <Plug>(easymotion-sl)             |  mapped to sln
    <Plug>(easymotion-fl)             |  mapped to fln
    <Plug>(easymotion-Fl)             |  mapped to Fln
    <Plug>(easymotion-bd-fl)          |  mapped to sln
    <Plug>(easymotion-tl)             |  mapped to tln
    <Plug>(easymotion-Tl)             |  mapped to Tln
    <Plug>(easymotion-bd-tl)          |  mapped to bd-tln

    <Plug>(easymotion-wl)             | 
    <Plug>(easymotion-bl)             | 
    <Plug>(easymotion-bd-wl)          | 
    <Plug>(easymotion-el)             | 
    <Plug>(easymotion-gel)            | 
    <Plug>(easymotion-bd-el)          | 
    <Plug>(easymotion-lineforward)    |
    <Plug>(easymotion-linebackward)   |
    <Plug>(easymotion-lineanywhere)   |
                                      
    Multi Input Find Motion           | Note
    ----------------------------------|---------------------------------
    <Plug>(easymotion-s2)             |  mapped to sn
    <Plug>(easymotion-f2)             |  mapped to fn
    <Plug>(easymotion-F2)             |  mapped to Fn
    <Plug>(easymotion-bd-f2)          |  mapped to sn
    <Plug>(easymotion-t2)             |  mapped to tn
    <Plug>(easymotion-T2)             |  mapped to Tn
    <Plug>(easymotion-bd-t2)          |  mapped to bd-tn
                                      |
    <Plug>(easymotion-sl2)            |  mapped to sln
    <Plug>(easymotion-fl2)            |  mapped to fln
    <Plug>(easymotion-Fl2)            |  mapped to Fln
    <Plug>(easymotion-tl2)            |  mapped to tln
    <Plug>(easymotion-Tl2)            |  mapped to Tl2
                                      |
    <Plug>(easymotion-sn)             | 
    <Plug>(easymotion-fn)             | 
    <Plug>(easymotion-Fn)             | 
    <Plug>(easymotion-bd-fn)          | 
    <Plug>(easymotion-tn)             | 
    <Plug>(easymotion-Tn)             | 
    <Plug>(easymotion-bd-tn)          | 
                                      |
    <Plug>(easymotion-sln)            | 
    <Plug>(easymotion-fln)            | 
    <Plug>(easymotion-Fln)            | 
    <Plug>(easymotion-bd-fln)         | 
    <Plug>(easymotion-tln)            | 
    <Plug>(easymotion-Tln)            | 
    <Plug>(easymotion-bd-tln)         | 

    Over Window Motion                | Note
    ----------------------------------|---------------------------------
    <Plug>(easymotion-overwin-f)      | UNSUPPORTED
    <Plug>(easymotion-overwin-f2)     | UNSUPPORTED
    <Plug>(easymotion-overwin-line)   | UNSUPPORTED
    <Plug>(easymotion-overwin-w)      | UNSUPPORTED


    Doesn't exist in EasyMotion       | Description
    ----------------------------------|----------------------------------
    <Plug>(acejump-linemarks)         | Analog of Line Motion in AceJump

15.4. TODO

  • 注释无法正常工作,包括那个插件
  • live template(IDE) ctrl-j
  • git commit(IDE) ctrl-k

15.5. 参考

16. 常用设置

  • 插件
    • IdeaVim
    • Material themes
  • font
  • 注释的缩进设置
  • encoding

16.1. 插件

先安装IdeaVimEasy-motion插件,然后重启.

调整键盘设置,将冲突的快捷键设置成vim或者ide

16.2. 字体

16.3. 编码

16.4. 主题

16.5. 拼写检查

16.6. SDK

SDK比如jdk通常在2个地方可以新建和编辑

  • project settings Ctrl-Alt-Shift-S
  • debug/run

16.7. 注释的缩进设置

Settings->Editor->Code Style->Java(or your language)->code generation

image-20210318111238040

TAG: vscode ide
文章作者 : Cocding