-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.ideavimrc
396 lines (339 loc) · 10.7 KB
/
.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
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
" ================================================
" ============ Basic settings ====================
" ================================================
set encoding=utf-8
" 自动缩进
set autoindent
" ide和vim marks同步
set ideamarks
" 禁用idea延迟宏
set showmatch
set timeout
set timeoutlen=500
set ideajoin
set wrap
"粘贴板共享
set clipboard+=unnamed
set clipboard+=ideaput
"移动光标的时候周围保留8行
" set scrolloff=8
"记住历史操作200条
set history=2000
"使用相对行号
set number
set relativenumber
"搜索大小写不敏感,除非包含大写
set smartcase
set ignorecase
"边输入边搜索
set incsearch
"搜索高亮
set hlsearch
" 显示当前模式
set showcmd
set showmode
" leaderkey
let mapleader=" "
let g:mapleader=" "
" 高亮当前block
nmap <leader>h :action Rainbow.ScopeOutsideHighlightingRestrainAction<CR>
" 输入法自动切换
let context_aware=0
let focus_auto=1
let keep_input_source_in_normal="com.apple.keylayout.ABC"
let keep_input_source_in_insert="im.rime.inputmethod.Squirrel.Hans"
set keep-english-in-normal-and-restore-in-insert
" ================================================
" ============ key bindings ====================
" ================================================
" Do not overwrite unnamed register with x and s
nnoremap x "_x
" nnoremap s "_s
" 交换$和g_
nnoremap <silent> $ g_
nnoremap <silent> g_ $
vnoremap <silent> $ g_
vnoremap <silent> g_ $
nnoremap <silent> L $
nnoremap <silent> H ^
nnoremap <silent> 0 ^
nnoremap <silent> ^ 0
vnoremap <silent> 0 ^
vnoremap <silent> ^ 0
" 命令行下CtrL + j/k上一个下一个
"cmap <C-j> <C-n>
"cmap <C-k> <C-p>
"tmap <C-j> <C-n>
"tmap <C-k> <C-p>
" 保存文件
nnoremap <silent> <leader>w :w<CR>
nnoremap <silent> <leader>wq :wqa!<CR>
" 退出
nnoremap <silent> <leader>q :qa!<CR>
" 当一行过长的时候jk移动可以替代gj和gk"
" nnoremap j gj
" nnoremap k gk
" vnoremap j gj
" vnoremap k gk
" 上下滚动浏览
"nnoremap <silent> <C-j> 5j
"nnoremap <silent> <C-k> 5k
"vnoremap <silent> <C-j> 5j
"vnoremap <silent> <C-k> 5k
nnoremap <silent> <C-u> 5k
nnoremap <silent> <C-d> 5j
vnoremap <silent> <C-u> 5k
vnoremap <silent> <C-d> 5j
" 开启魔术搜索
"set magic
"nnoremap / /\\v
"vnoremap / /\\v
nmap n nzz
nmap N Nzz
vmap n nzz
vmap N Nzz
"visual 模式 下 按* 号 搜索 光标选中的内容(对已选中的内容进行查找)
vmap * "ry/<C-R>r<CR>
" 在visual模式下缩进代码,缩进之后任然可以继续选中区域
vnoremap <silent> < <gv
vnoremap <silent> > >gv
" 可视化模式下,选中行可以上下移动
vmap J <action>(MoveLineDown)
vmap K <action>(MoveLineUp)
=============== 分屏快捷键 ====================
" 后退 ideavim 2.0.0修复了这个问题
" nmap <C-o> <action>(Back)
" 前进
" nmap <C-i> <action>(Forward)
" 分屏快捷键
" nnoremap <silent> s <NOP>
nnoremap <silent> sv :vsp<CR>
nnoremap <silent> sh :sp<CR>
" 关闭当前
nnoremap <silent> sc <C-w>c
" alt + hjkl 窗口之间跳转, win中生效
nnoremap <silent> <C-h> <C-w>h
nnoremap <silent> <C-j> <C-w>j
nnoremap <silent> <C-k> <C-w>k
nnoremap <silent> <C-l> <C-w>l
" 左右比例控制
nmap <C-left> <action>(StretchSplitToLeft)
nmap <C-right> <action>(StretchSplitToRight)
" 上下比例控制
nmap <C-up> <action>(StretchSplitToTop)
nmap <C-down> <action>(StretchSplitToBottom)
" 相等比例
" nmap s= <action>(tabshifter.Actions.EqualSizeSplit)
" 关闭当前的窗口
nmap <leader>c <action>(CloseEditor)
" nmap <leader>wo <action>(CloseAllEditorsButActive)
" map <C-w> <action>(CloseTab) \| <action>(CloseContent) \| <action>(CloseThumbnails)
" nmap <M-w> <action>(CloseContent)
" 关闭所有窗口 ️
" nmap sa <action>(CloseAllEditors)
" 重新打开关闭窗口
" nmap sr <action>(ReopenClosedTab)
" 关闭除了激活窗口以外的窗口
nmap <leader>bo <action>(CloseAllEditorsButActive)
" 窗口最大化,并且隐藏其他窗口
nmap sm <action>(UnsplitAll) \| <action>(HideAllWindows)
" 关闭搜索高亮
nmap <leader>nh :nohlsearch<CR>
" previous method
noremap [[ <ESC>:action MethodUp<CR>
" next method
noremap ]] <ESC>:action MethodDown<CR>
" 上一个修改点
nmap (( <Action>(VcsShowPrevChangeMarker)
" 下一个修改点
nmap )) <Action>(VcsShowNextChangeMarker)
" 选择模式扩大选择范围
vmap v <Action>(EditorSelectWord)
" 选择模式缩小选择范围
vmap V <Action>(EditorUnSelectWord)
" 文件树
" o open ,go open cursor not move , i hsplit , s vsplit
set NERDTree
nnoremap <leader>o :NERDTreeFocus<CR>
" 将此文件在文件浏览器中定位
nnoremap <leader>tw :NERDTreeFind<CR>
nnoremap <leader>e :NERDTreeToggle<CR>
nnoremap <leader>tr :NERDTreeRefreshRoot<CR>
" 切换tab
nmap ]b <action>(NextTab)
nmap [b <action>(PreviousTab)
nmap <Tab> <action>(NextTab)
nmap <S-Tab> <action>(PreviousTab)
" 搜索框
nmap <leader>fe <action>(SearchEverywhere)
nmap <leader>ff <action>(GotoFile)
nmap <leader>fp <action>(FindInPath)
nmap <leader>fa <Action>(GotoAction)
nmap <leader>fc <Action>(GotoClass)
" 注释方法
nmap <C-/> <action>(CommentByLineComment)
vmap <C-/> <action>(CommentByLineComment)
" 终端
" 打开终端
nmap <leader>th <Action>(ActivateTerminalToolWindow)
" 新建终端
" nmap <A-w> <Action>(Terminal.OpenInTerminal)
" 激活终端
" nmap <leader>ta <Action>(ActivateTerminalToolWindow)
" 隐藏终端
" nmap <leader>th <action>(HideAllWindows)
" 设置多光标
set multiple-cursors
nmap <C-n> <Plug>NextWholeOccurrence
xmap <C-n> <Plug>NextWholeOccurrence
nmap <C-x> <Plug>SkipOccurrence
xmap <C-x> <Plug>SkipOccurrence
nmap <C-m> <Plug>RemoveOccurrence
xmap <C-m> <Plug>RemoveOccurrence
nmap <S-C-n> <Plug>AllWholeOccurrences
xmap <S-C-n> <Plug>AllWholeOccurrences
" 可视化模式下,paste之后不会替换yank的内容,这里可以被下面的替换组件代替
vmap p "_dP
" 设置替换插件
" set ReplaceWithRegister
" nmap s <Plug>ReplaceWithRegisterOperator
" nmap ss <Plug>ReplaceWithRegisterLine
" xmap p <Plug>ReplaceWithRegisterVisual
" surround插件
" ds 删除, ys 新增,vS 虚拟化模式增加
set surround
" exchange插件
" set exchange
" nmap sx <Plug>(Exchange)
" nmap sxx <Plug>(ExchangeLine)
" xmap X <Plug>(Exchange)
" nmap sxc <Plug>(ExchangeClear)
" 快速选定函数和方法
" 该方法添加了一个函数的motion对象,叫做a, daa删除函数参数包括逗号,dia删除函数参数不包括逗号,同理y,d,c都可以使用
let g:argtextobj_pairs="[:],(:),<:>"
set argtextobj
" 快速复制整个文档,这边不主动改建,不然因为延迟机制,会变慢
set textobj-entire
" 复制全部文档,包括头部空行
" nnoremap <silent> ae <Plug>(textobj-entire-a)
" 复制全部文档,不包括头部空行
" nnoremap <silent> ie <Plug>(textobj-entire-i)
" easy motion插件, 如果用大写字母前进,那么就会选中所有内容
set easymotion
"nmap f <Plug>(easymotion-f)
"nmap F <Plug>(easymotion-F)
"nmap t <Plug>(easymotion-t)
"nmap T <Plug>(easymotion-T)
nmap <leader>j <Plug>(easymotion-j)
nmap <leader>k <Plug>(easymotion-k)
nmap s <Plug>(easymotion-s)
nmap <leader>nj <Plug>(easymotion-n)
nmap <leader>nk <Plug>(easymotion-N)
" 设置高亮插件
set highlightedyank
let g:highlightedyank_highlight_color = "rgba(100,149,237, 111)"
" 折叠代码块
nmap za <Action>(CollapseRegion)
nmap zo <Action>(ExpandRegion)
nmap zA <Action>(CollapseAllRegions)
nmap zO <Action>(ExpandAllRegions)
=======================================================
================== lsp ================================
=======================================================
" 寻找下一个错误
nmap ]d <action>(GotoNextError)
" 回到上一个错误
nmap [d <action>(GotoPreviousError)
" 去到函数申明的地方
nmap gd <action>(GotoDeclaration)
" 去到函数类型声明的地方
nmap gy <action>(GotoTypeDeclaration)
" 进入测试方法
nmap gE <action>(GotoTest)
" 回到函数方法上
nmap gm <action>(MethodUp)
" 寻找接口实现的
nmap gI <action>(GotoImplementation)
" 格式化代码
nmap <leader>lf <action>(ReformatCode) \| <action>(OptimizeImports) \| <action>(Javascript.Linters.EsLint.Fix)
" 查找最近使用的地方
" nmap <leader>ll <action>(RecentLocations)
" lsp: 重命名
nmap <leader>lr <action>(RenameElement)
" 展示目的
nmap <leader>la <action>(ShowIntentionActions)
" 展示错误提示
nmap <leader>ld <action>(ShowErrorDescription)
nmap gl <action>(ShowErrorDescription)
" 查看文件的structure
nmap <leader>ls <action>(FileStructurePopup)
" 查看参数
nmap <leader>lp <action>(ParameterInfo)
" 查看类型
nmap <leader>lt <action>(ExpressionTypeInfo)
" 查看java doc 一般用来查看数据类型
nmap <leader>lj <action>(QuickJavaDoc)
nmap K <action>(QuickJavaDoc)
" 调用Generate
nmap <leader>lg <action>(Generate)
" 代码包裹一层
vmap <leader>lw <action>(SurroundWith)
" 代码去掉包裹
vmap <leader>lW <action>(Unwrap)
================================================================================================
= e开头,用于抽离方法====================================
================================================================================================
" e: 用于抽离方法,可视化模式下,将选中到变量抽离出来
" extract method/function
vmap <leader>em <action>(ExtractMethod)
" extract constant
vmap <leader>ec <action>(IntroduceConstant)
" extract field
vmap <leader>ef <action>(IntroduceField)
" extract variable
vmap <leader>ev <action>(IntroduceVariable)
" Inline variable
vmap <leader>ei <action>(Inline)
=======================================================
================= debug ===============================
=======================================================
" nmap <leader>dr <Action>(ContextRun)
" nmap <leader>dc <Action>(RunClass)
" nmap <leader>dt <Action>(RerunTests)
" nmap <leader>df <Action>(RerunFailedTests)
" nmap <leader>dp <Action>(ChooseRunConfiguration)
nmap <leader>dr <Action>(Run)
nmap <leader>dd <Action>(Debug)
"=============================================================
" 默认键位配置
"=============================================================
"sethandler <C-C> n-v:ide i:vim
" IDEA
sethandler <C-B> a:ide
sethandler <C-S> a:ide
sethandler <C-E> a:ide
sethandler <C-[> a:ide
" VIM
sethandler <C-T> a:vim
sethandler <C-Q> a:vim
sethandler <C-V> a:vim
sethandler <C-U> a:vim
sethandler <C-D> a:vim
sethandler <C-H> a:vim
sethandler <C-J> n-v:vim i:ide
sethandler <C-K> n-v:vim i:ide
sethandler <C-L> a:vim
sethandler <C-M> a:vim
sethandler <C-N> a:vim
sethandler <C-C> a:vim
sethandler <C-P> a:vim
sethandler <C-F> a:vim
sethandler <C-I> a:vim
sethandler <C-O> a:vim
sethandler <C-W> a:vim
sethandler <C-A> a:vim
"=============================================================
" 默认键位配置
"=============================================================
"imap <C-K> <Action>(EditorUp)
"imap <C-J> <Action>(EditorDown)