-
Notifications
You must be signed in to change notification settings - Fork 1
/
ideavimrc
325 lines (282 loc) · 9.76 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
" basic stuff
set hlsearch
set scrolloff=5
set ignorecase smartcase
set showmode
set history=1000
set incsearch
set clipboard+=unnamed
set relativenumber
set ReplaceWithRegister
set visualbell
set idearefactormode=visual
set showcmd
set showmode
set ideastatusicon=gray
set virtualedit=onemore
" extensions
set surround
set multiple-cursors
set highlightedyank
set NERDTree
set argtextobj
set sneak
set quickscope
set switch
set peekaboo
set functiontextobj
set commentary
" set the various handlers
sethandler <C-a> a:vim
sethandler <C-b> a:vim
sethandler <C-c> a:vim
sethandler <C-d> a:vim
sethandler <C-e> a:vim
sethandler <C-f> a:vim
sethandler <C-g> a:vim
sethandler <C-h> a:vim
sethandler <C-i> a:vim
sethandler <C-j> a:ide
sethandler <C-k> a:ide
sethandler <C-l> a:vim
sethandler <C-m> a:vim
sethandler <C-n> a:vim
sethandler <C-o> a:vim
sethandler <C-p> a:vim
sethandler <C-q> a:vim
sethandler <C-r> a:vim
sethandler <C-s> a:vim
sethandler <C-t> a:vim
sethandler <C-u> a:vim
sethandler <C-v> a:vim
sethandler <C-v> a:vim
sethandler <C-w> a:vim
sethandler <C-x> a:vim
sethandler <C-y> a:vim
sethandler <C-z> a:vim
" WhichKey configuration (plugin is toggled by <leader>8)
let g:WhichKey_FontSize = 20
let g:WhichKey_PrefixColor = "#a403fe"
let g:WhichKey_CommandColor = "#01ffff"
let g:WhichKey_PrefixStyle = "bold"
let g:WhichKey_KeyStyle = "italic"
let g:WhichKey_SortOrder = "by_key_prefix_first"
let g:WhichKey_ShowTypedSequence = "true"
" register leader
let mapleader = " "
nmap <leader>ss :Switch<cr>
nmap <leader>SS :SwitchReverse<cr>
let g:WhichKeyDesc_switch = "<leader>ss Switch"
let g:WhichKeyDesc_switch_reverse = "<leader>ss Switch"w
" Enable all patterns from multiple groups
let g:switch_definitions = 'group:basic,group:java,group:javascript'
" After block yank and paste, move cursor to the end of operated text and don't override register
vnoremap p "_dP`]
nnoremap p p`]
" Center screen after screen movement
nnoremap H Hzz
nnoremap M Mzz
nnoremap L Lzz
" Y yank whole line by default
vnoremap y ygv<Esc>$
nnoremap Y y$
" Yank and paste from clipboard
nnoremap ,y "+y
vnoremap ,y "+y
nnoremap ,yy "+yy
nnoremap ,p "+p
" have x (removes single character) not go into the default registry
nnoremap x "_x
" Make X an operator that removes without placing text in the default registry
nmap X "_d
nmap XX "_dd
vmap X "_d
vmap x "_d
" don't yank to default register when changing something
nnoremap c "xc
xnoremap c "xc
" Change line, better use S for this.
nmap cc 1S
" Copy Word
nmap ,c yiw
" Select word
nmap ,v viw
" Reselect last-pasted text
nnoremap gp `[v`]
" Center screen when jumping to next match
nnoremap n nzz
nnoremap N Nzz
vnoremap n nzz
vnoremap N Nzz
" Center screen when moving up and down
nnoremap <C-u> <C-u>zz
nnoremap <C-o> <C-d>zz
vnoremap <C-u> <C-u>zz
vnoremap <C-o> <C-d>zz
" easy window navigation
nnoremap <a-k> gT
nnoremap <a-j> gt
nnoremap <c-s-tab> gT
nnoremap <c-tab> gt
" clear the search buffer when hitting return
nnoremap <leader><cr> :nohlsearch<cr>
" code Refactoring
:map <leader>rr <Action>(RenameElement)
:map <leader>RR <Action>(Refactorings.QuickListPopupAction)
:map <leader>sw <Action>(SurroundWith)
:map <leader>oi <Action>(OptimizeImports)
let g:WhichKeyDesc_rename_element = "<leader>rr Rename element"
let g:WhichKeyDesc_refactors = "<leader>RR Refactorings"
let g:WhichKeyDesc_surround_with = "<leader>sw Surround with"
let g:WhichKeyDesc_optimize_import = "<leader>sw Optimize import"
" stuff
:map <leader>er <Action>(QuickJavaDoc)
:map <leader>ee <Action>(ShowErrorDescription)
:map <leader>hh <Action>(QuickImplementations)
:map <leader>hj <Action>(ShowHoverInfo)
let g:WhichKeyDesc_quick_java_doc = "<leader>er Quick docs"
let g:WhichKeyDesc_show_error_description = "<leader>ee Show error description"
let g:WhichKeyDesc_quick_implementations = "<leader>hh Quick implementations"
let g:WhichKeyDesc_show_info = "<leader>hj Show info"
" breakpoints
:map <leader>ub <Action>(ToggleLineBreakpoint)
:map <leader>us <Action>(ViewBreakpoints)
:map <leader>ur <Action>(Debugger.RemoveAllBreakpoints)
let g:WhichKeyDesc_toggle_line_breakpoint = "<leader>ub Toggle line breakpoint"
let g:WhichKeyDesc_view_breakpoints = "<leader>us View breakpoints"
let g:WhichKeyDesc_remove_all_breakpoints = "<leader>ur Remove all breakpoints"
" bookmarks
nmap <leader>bs <Action>(ShowBookmarks)
nmap <leader>bt <Action>(ActivateBookmarksToolWindow)
nmap <leader>bb <Action>(ToggleBookmark)
nmap <leader>be <Action>(EditBookmark)
nmap <leader>bp <Action>(GotoPreviousBookmark)
nmap <leader>bn <Action>(GotoNextBookmark)
let g:WhichKeyDesc_bookmarks = "<leader>b Bookmarks"
let g:WhichKeyDesc_bookmarks_menu = "<leader>bm Bookmark Menu"
let g:WhichKeyDesc_bookmarks_show = "<leader>bs Show Bookmarks"
let g:WhichKeyDesc_bookmarks_tool = "<leader>bt Bookmark Tool"
let g:WhichKeyDesc_bookmarks_toggle_bookmark = "<leader>bb Toggle Bookmark"
let g:WhichKeyDesc_bookmarks_edit = "<leader>be Edit Bookmark"
let g:WhichKeyDesc_bookmarks_prev = "<leader>bp Previous Bookmark"
let g:WhichKeyDesc_bookmarks_next = "<leader>bn Next Bookmark"
" ace
:map ff <Action>(AceAction)
:map fv <Action>(AceTargetAction)
:map fl <Action>(AceLineAction)
let g:WhichKeyDesc_ace_action = "ff Ace action"
let g:WhichKeyDesc_ace_target_action = "fv Ace target action"
let g:WhichKeyDesc_ace_line_action = "fl Ace line action"
" various functionality
:map <leader>hu <Action>(HighlightUsagesInFile)
:map <leader>rl <Action>(RecentLocations)
:map gy <Action>(RecentChangedFiles)
:map <leader>sh <Action>(LocalHistory.ShowHistory)
:map <leader>m <Action>(ShowIntentionActions)
:map <leader>o <Action>(FileStructurePopup)
:map <leader>pw <Action>(SelectInProjectView)
:map <leader>rt <Action>(RunContextGroup)
:map gh <Action>(GotoDeclaration)
:map <leader>so <Action>(SelectAllOccurrences)
let g:WhichKeyDesc_highlight_usages_in_file = "<leader>hu Highlight usages in file"
let g:WhichKeyDesc_recent_locations = "<leader>rl Recent locations"
let g:WhichKeyDesc_recent_changed_files = "gy Recent changed files"
let g:WhichKeyDesc_show_history = "<leader>sh Show history"
let g:WhichKeyDesc_show_intent_actions = "<leader>m Show intent actions"
let g:WhichKeyDesc_file_structure_popup = "<leader>o File structure popup"
let g:WhichKeyDesc_select_in_project_view = "<leader>pw Select in project view"
let g:WhichKeyDesc_run_context_group = "<leader>rt Run context group"
let g:WhichKeyDesc_goto_declaration = "gh Goto declaration"
let g:WhichKeyDesc_select_all_occurrences = "<leader>so Select all occurrences"
xnoremap < <gv
xnoremap > >gv
" copy whole file
nmap <C-a> ggVG"+y
" code navigation
" :map <leader>j <Action>(MethodDown)
" :map <leader>J <Action>(MethodUp)
:map g[ <Action>(GotoNextError)
:map g] <Action>(GotoPreviousError)
:map <leader>k <Action>(JumpToLastChange)
:map <leader>K <Action>(JumpToNextChange)
" :map ga <Action>(VcsShowNextChangeMarker)
" :map gø <Action>(VcsShowPrevChangeMarker)
:map gn <Action>(GotoNextElementUnderCaretUsage)
:map gN <Action>(GotoPrevElementUnderCaretUsage)
let g:WhichKeyDesc_goto_next_error = "g] Goto next error"
let g:WhichKeyDesc_goto_previous_error = "g[ Goto previous error"
let g:WhichKeyDesc_jump_to_last_change = "<leader>k Jump to last change"
let g:WhichKeyDesc_jump_to_next_change = "<leader>K Jump to next change"
let g:WhichKeyDesc_goto_next_element_under_caret_usage = "gn Goto next element under caret usage"
let g:WhichKeyDesc_goto_prev_element_under_caret_usage = "gN Goto previous element under caret usage"
" splits
:map <leader>i <Action>(PrevSplitter)
:map <c-b> <Action>(SplitVertically)
" built-in navigation to navigated items works better
:nmap <c-o> <Action>(Back)
:nmap <c-i> <Action>(Forward)
" but preserve ideavim defaults
:map g<c-o> <c-o>
:map g<c-i> <c-i>
" close stuff
:map <leader>q <Action>(CloseEditor)
:map <leader>Q <Action>(CloseAllEditors)
:map <leader>w <Action>(CloseAllEditorsButActive)
" reactivate some IDEA shortcuts
:map <c-n> <Action>(SearchEverywhere)
:map <leader>gg <Action>(GotoFile)
:map <c-b> <Action>(ShowUsages)
:map <c-s> <Action>(SaveAll)
:map <c-c> <Action>(GotoImplementation)
" run stuff
:map <leader>cg <Action>(ChooseRunConfiguration)
:map <leader>dg <Action>(ChooseDebugConfiguration)
:map <leader>1 <Action>(Run)
:map <leader>2 <Action>(Debug)
:map <leader>0 <Action>(Stop)
let g:WhichKeyDesc_choose_run_configuration = "<leader>cg Choose run configuration"
let g:WhichKeyDesc_choose_debug_configuration = "<leader>dg Choose debug configuration"
let g:WhichKeyDesc_run = "<leader>1 Run"
let g:WhichKeyDesc_debug = "<leader>2 Debug"
let g:WhichKeyDesc_stop = "<leader>0 Stop"
" other things
:map <leader>ns <Action>(NewScratchFile)
:map <leader>an <Action>(Annotate)
:map <leader>tw <Action>(ActivateProjectToolWindow)
let g:WhichKeyDesc_new_scratch_file = "<leader>ns New scratch file"
let g:WhichKeyDesc_annotate = "<leader>an Annotate"
let g:WhichKeyDesc_activate_project_window = "<leader>tw Activate project tool window"
" toggle line number relative
function! NumberToggle()
if(&relativenumber == 1)
set norelativenumber
else
set relativenumber number
endif
endfunction
nnoremap <leader><Tab> :call NumberToggle()<cr>
let g:WhichKeyDesc_toggle_line_numbers = "<leader><Tab> Toggle line numbers"
" toggle which-key plugin
let s:whichKeyEnabled = 0
function! WhichKeyToggle()
if s:whichKeyEnabled
set which-key!
set notimeout!
let s:whichKeyEnabled = 0
else
set which-key
set notimeout
let s:whichKeyEnabled = 1
endif
endfunction
nnoremap <leader>8 :call WhichKeyToggle()<cr>
let g:WhichKeyDesc_toggle_which_key = "<leader>8 Toggle WhichKey"
" source
:map <leader>9 <Action>(IdeaVim.ReloadVimRc.reload)
let g:WhichKeyDesc_reload_vim_rc = "<leader>9 Reload VimRc"
nmap <C-n> <Plug>NextWholeOccurrence
xmap <C-n> <Plug>NextWholeOccurrence
nmap g<C-n> <Plug>NextOccurrence
xmap g<C-n> <Plug>NextOccurrence
xmap <C-x> <Plug>SkipOccurrence
xmap <C-p> <Plug>RemoveOccurrence