-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.ideavimrc
328 lines (276 loc) · 8.94 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
let mapleader=' '
" ============= PLUGINS =============
set surround
set multiple-cursors
set commentary
set argtextobj
set ReplaceWithRegister
set exchange
set highlightedyank
set matchit
" highlightedyank
let g:highlightedyank_highlight_duration = '300'
let g:highlightedyank_highlight_color = 'rgb(131, 148, 150, 120)'
" surround
nmap S ysiW
" ReplaceWithRegister
nmap ö <PLug>ReplaceWithRegisterOperator
nmap Ö <PLug>ReplaceWithRegisterOperator$
nmap öö <PLug>ReplaceWithRegisterLine
xmap ö <PLug>ReplaceWithRegisterVisual
" Text objects for delimiters.
nnoremap ci/ T/ct/
nnoremap ca/ F/ct/
nnoremap ci, T,ct,
nnoremap ca, F,ct,
nnoremap ci. T.ct.
nnoremap ca. F.ct.
nnoremap ci_ T_ct_
nnoremap ca_ F_ct_
nnoremap ci- T-ct-
nnoremap ca- F-ct-
nnoremap ci% T%ct%
nnoremap ca% F%ct%
nnoremap ci= T=ct=
nnoremap ca= F=ct=
nnoremap ci? T?ct?
nnoremap ca? F?ct?
nnoremap ci! T!ct!
nnoremap ca! F!ct!
nnoremap ci& T&ct&
nnoremap ca& F&ct&
nnoremap di/ T/dt/
nnoremap da/ F/dt/
nnoremap di, T,dt,
nnoremap da, F,dt,
nnoremap di. T.dt.
nnoremap da. F.dt.
nnoremap di_ T_dt_
nnoremap da_ F_dt_
nnoremap di- T-dt-
nnoremap da- F-dt-
nnoremap di% T%dt%
nnoremap da% F%dt%
nnoremap di= T=dt=
nnoremap da= F=dt=
nnoremap di? T?dt?
nnoremap da? F?dt?
nnoremap di! T!dt!
nnoremap da! F!dt!
nnoremap di& T&dt&
nnoremap da& F&dt&
nnoremap vi/ T/vt/
nnoremap va/ F/vt/
nnoremap vi, T,vt,
nnoremap va, F,vt,
nnoremap vi. T.vt.
nnoremap va. F.vt.
nnoremap vi_ T_vt_
nnoremap va_ F_vt_
nnoremap vi- T-vt-
nnoremap va- F-vt-
nnoremap vi% T%vt%
nnoremap va% F%vt%
nnoremap vi= T=vt=
nnoremap va= F=vt=
nnoremap vi? T?vt?
nnoremap va? F?vt?
nnoremap vi! T!vt!
nnoremap va! F!vt!
nnoremap vi& T&vt&
nnoremap va& F&vt&
nnoremap yi/ T/yt/
nnoremap ya/ F/yt/
nnoremap yi, T,yt,
nnoremap ya, F,yt,
nnoremap yi. T.yt.
nnoremap ya. F.yt.
nnoremap yi_ T_yt_
nnoremap ya_ F_yt_
nnoremap yi- T-yt-
nnoremap ya- F-yt-
nnoremap yi% T%yt%
nnoremap ya% F%yt%
nnoremap yi= T=yt=
nnoremap ya= F=yt=
nnoremap yi? T?yt?
nnoremap ya? F?yt?
nnoremap yi! T!yt!
nnoremap ya! F!yt!
nnoremap yi& T&yt&
nnoremap ya& F&yt&
" ============= GENERAL =============
" Search settings.
set incsearch hlsearch ignorecase smartcase gdefault
set ideajoin " use the IDE's join/J behavior
set selectmode=ideaselection " use select mode only when IDE sets a selection
set timeoutlen=1000 " timeout for keymappings
set clipboard=unnamed,ideaput " use system clipboard with idea's pasting logic
set scrolloff=1 " pad scrolling with one line
set showmode " show current mode in statusbar
set showcmd " show partial command in statusbar
set visualbell " removes errorbells
" ============= MAPPINGS =============
" Move between splits.
nnoremap <A-L> <C-W>l
nnoremap <A-H> <C-W>h
nnoremap <A-J> <C-W>j
nnoremap <A-K> <C-W>k
nmap <C-W>= <Action>(MaximizeEditorInSplit)
" Makes these easier to use.
noremap , :
noremap : ;
noremap ; ,
nnoremap + $
xnoremap + $
" Make Y behave the same way as D and C.
nnoremap Y y$
" Makes v and V more consistent with other commands.
nnoremap vv V
nnoremap V <C-V>$
" Cleaner to use when cursor doesn't move.
nnoremap J Jh
" Make K the logical opposite of J.
nnoremap K a<CR><Esc>k$
" Change enter behavior.
nnoremap <CR> mqo<Esc>`q
" FIXME: This doesn't keep cursor on the same place.
nnoremap <S-Enter> mqO<Esc>`q
" Better way to indent.
nnoremap <BS> <<
nnoremap <TAB> >>
xnoremap <BS> <gv
xnoremap <TAB> >gv
" Persistent visuals.
xnoremap > >gv
xnoremap < <gv
xnoremap <C-X> <C-X>gv
xnoremap <C-A> <C-A>gv
" Q plays back q macro.
nnoremap Q @q
" Repeat the last substitution.
nnoremap & :&&<CR>
xnoremap & :s//~/&<CR>:noh<CR>
" Search for selected text.
xnoremap * "zy/<C-R>z<CR>
xnoremap # "zy?<C-R>z<CR>
" Easier substitution.
nnoremap <Leader>, :%s/
xnoremap <Leader>, :s/
" Split line on a comma.
nnoremap \ f,a<CR><Esc>^
" Split function arguments or list members into their own lines.
nnoremap <Leader>\ mq^f,`qv%J`qa<CR><Esc>k$%i<CR><Esc>k:s/, *\($\)\@!/,\r<CR>:noh<CR>`qv%=`q
" Type a delimiter for splitting the line into separate lines.
nnoremap <Leader><Leader>\ :s//&\r<Left><Left><Left><Left>
xnoremap <Leader><Leader>\ :s//&\r<Left><Left><Left><Left>
" Clear highlights.
nnoremap <Esc> <Esc>:noh<CR>
" Change eol comment to line comment and vice versa.
nnoremap ä :s,^\(\s*\)\(\S.\{-}\)\s*\(\(#\\\|//\).*\)$,\1\3\r\1\2<CR>:noh<CR>
nnoremap Ä :s,^\s*\(\(#\\\|//\).*\)$\n\(.\{-}\)\s*$,\3 \1<CR>:noh<CR>
" Select previously yanked text.
nnoremap gb `[v`]
" Paste to the next or previous line.
nnoremap gp o<Esc>p^
nnoremap gP O<Esc>p^
" =========== IDEAVIM MAPPINGS ===========
" Go to the first occurance of the symbol in the file.
nnoremap gf "zyiwgg/\C\\<\\><Left><Left><BS><C-R>z<CR>:noh<CR>
" Go to the declaration of the first inherited parent class in Python.
nmap go ?^class <CR>f(/[A-Z]<CR><Action>(GotoDeclarationOnly),noh<CR>
nmap gd <Action>(GotoDeclarationOnly)
nmap gr <Action>(GotoRelated)
nmap gs <Action>(GotoSuperMethod)
nmap gt <Action>(GotoTypeDeclaration)
nmap gy <Action>(GotoTest)
" Makes using marks a lot better, ` mapping clashes with surround.
nmap ' <Action>(ShowBookmarks)
nmap m <Action>(ToggleBookmarkWithMnemonic)
" These only make sense as IdeaVim mappings, since Vim defines so many ]x mappings.
nmap [ <Action>(MethodUp)
nmap ] <Action>(MethodDown)
map <Leader>a <Action>(GotoAction)
nmap <Leader>b <Action>(ToggleLineBreakpoint)
nmap <Leader>c <Action>(GotoClass)
nmap <Leader>d <Action>(QuickJavaDoc)
nmap <Leader>e <Action>(Run)
nmap <Leader>f <Action>(GotoFile)
nmap <Leader>g <Action>(ManageRecentProjects)
nmap <Leader>h <Action>(FileStructurePopup)
nmap <Leader>i <Action>(GotoImplementation)
nmap <Leader>j <Action>(ShowNavBar)
noremap <Leader>k mo:action KJumpAction<CR>
nmap <Leader>l <Action>(FindInPath)
nmap <Leader>m <Action>(RecentChangedFiles)
nmap <Leader>n <Action>(LocalHistory.ShowHistory)
xmap <Leader>n <Action>(LocalHistory.ShowSelectionHistory)
nmap <Leader>o <Action>(ShowReformatFileDialog)
xmap <Leader>o <Action>(ReformatCode)
nmap <Leader>p <Action>(PasteMultiple)
nmap <Leader>q <Action>(ChooseRunConfiguration)
nmap <Leader>r <Action>(RenameElement)
nmap <Leader>s <Action>(GotoSymbol)
map <Leader>t <Action>(ExpressionTypeInfo)
nmap <Leader>u <Action>(ShowUsages)
nmap <Leader>v <Action>(ViewBreakpoints)
nmap <Leader>w <Action>(Debug)
map <Leader>x <Action>(Refactorings.QuickListPopupAction)
nmap <Leader>y <Action>(ShowErrorDescription)
nmap <Leader>z <Action>(RenameFile)
nnoremap <Leader>ä :s,^\(.\{-}\)\s*\(\(#\\\|//\).*\)$,\1<CR>:noh<CR>
nmap <Leader>ö <Action>(HighlightUsagesInFile)
nmap <Leader>< <Action>(CopyReferencePopupGroup)
map <Leader>] <Action>(SurroundWith)
map <Leader>[ <Action>(Unwrap)
nmap <Leader>' <Action>(Generate)
nmap <Leader>` <Action>(RerunFailedTests)
nmap <Leader># <Action>(ActivateDatabaseToolWindow)
nmap <Leader>% <Action>(TypeScript.Restart.Service)
nmap <Leader>& <Action>(Git.ResolveConflicts)
nmap <Leader>1 <Action>(InspectCode)
nmap <Leader>2 <Action>(DebugClass)
nmap <Leader>3 <Action>(RunClass)
nmap <Leader>4 <Action>(Vcs.ShowTabbedFileHistory)
xmap <Leader>4 <Action>(Vcs.ShowHistoryForBlock)
nmap <Leader>5 <Action>(Annotate)
nmap <Leader>6 <Action>(Compare.SameVersion)
nmap <Leader>7 <Action>(ReplaceInPath)
nmap <Leader>8 <Action>(ToggleBreakpointEnabled)
nmap <Leader>9 <Action>(QuickImplementations)
nmap <Leader>0 <Action>(Django.RunManageTaskAction)
nmap <Leader><Esc> <Action>(ClearAllNotifications)
nmap <C-H> <Action>(ParameterInfo)
nmap <C-J> <Action>(EditorCloneCaretBelow)
nmap <C-K> <Action>(EditorCloneCaretAbove)
imap <C-H> <Action>(ParameterInfo)
imap <C-J> <Action>(EditorCloneCaretBelow)
imap <C-K> <Action>(EditorCloneCaretAbove)
imap <C-X> <Action>(CodeCompletion)
nmap <C-P> <Action>(GotoPreviousError)
nmap <C-N> <Action>(GotoNextError)
nmap <C-S-P> <Action>(VcsShowPrevChangeMarker)
nmap <C-S-N> <Action>(VcsShowNextChangeMarker)
nmap <C-O> <Action>(Back)
nmap <C-I> <Action>(Forward)
nmap <F10> <Action>(ExportSettings)
nmap <F11> <Action>(ImportSettings)
nnoremap <F12> :source ~/.ideavimrc<CR>
sethandler a:vim
sethandler <C-C> a:ide " Stop (execution)
sethandler <C-L> a:ide " Complete Current Statement
sethandler <C-M> a:ide " Add Selection for Next Occurence (clone caret)
sethandler <C-,> a:ide " Unselect Occurence (unclone caret)
sethandler <C-1> a:ide " Hide All Tool Windows
sethandler <C-2> a:ide " Project (tool window)
sethandler <C-3> a:ide " Run (tool window)
sethandler <C-4> a:ide " Debug (tool window)
sethandler <C-5> a:ide " Terminal (tool window)
sethandler <C-6> a:ide " Python or Debug Console (tool window)
sethandler <C-7> a:ide " Git (tool window)
sethandler <C-8> a:ide " Build (tool window)
sethandler <C-9> a:ide " Type Hierarchy (sidebar)
sethandler <C-0> a:ide " Call Hierarchy (sidebar)
sethandler <S-Tab> a:ide " Copilot: Apply Completions to Editor / Copilot: Show Completions / Insert Inline Proposal
sethandler <C-[> a:ide " Copilot: Show Previous Completions
sethandler <C-]> a:ide " Copilot: Show Next Completions