-
Notifications
You must be signed in to change notification settings - Fork 0
/
.ideavimrc
182 lines (147 loc) · 5.33 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
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Space as <leader>.
nnoremap <Space> <nop>
let mapleader=" "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ## Basic options
"
" See https://github.com/JetBrains/ideavim/wiki/%22set%22-commands
" for the List of Supported Set Commands.
set showmode
set scrolloff=5
set keymodel=startsel,stopsel
" set selectmode=mouse,key
" set ideavimsupport+=sigleline
set ideajoin
"set selection=exclusive
"set clipboard+=unnamed
set timeoutlen=3000
set startofline
set whichwrap+=<,>,h,l,[,]
set ignorecase
set smartcase
set incsearch
set iskeyword=@,48-57,_,128-167,224-235,-,?,!,:,<,>,*
set number
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ## Emulated Vim Plugins
"
" See https://github.com/JetBrains/ideavim/wiki/Emulated-plugins.
set surround
let g:highlightedyank_highlight_color = "rgba(255, 246, 143, 255)"
let g:highlightedyank_highlight_duration = "1000"
set highlightedyank
set commentary
set matchit
set ReplaceWithRegister
set sneak
let g:qs_highlight_on_keys = ['f', 'F', 't', 'T']
set quickscope
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ## Basic mappings.
" Windows clipboard.
" There is no `smap` command so we use pair of vmap/xmap to create different
" mappings for visual and select modes.
nmap <C-C> "*yy
vmap <C-C> <C-G>"*y
xmap <C-C> "*y
" Toggle settings.
nmap <leader>// :set hlsearch!<CR>
" Expand selection.
" nmap + <Action>(EditorSelectWord)
" xmap + <Action>(EditorSelectWord)
" xmap _ <Action>(EditorUnSelectWord)
" Insert mode.
nmap <leader>i i<Space><Left>
nmap <leader>I i_<CR><Up><End><BS>
nmap <leader>o %a<CR>
nmap <leader>a %a
" Paste linewise.
nmap <leader>p :put<CR>
nmap <leader>P :-1put<CR>
" Paste as plain text via clipboard.
nmap <leader>gp :let @+=@"<CR><Action>(EditorPasteSimple)
" Insert new line in normal mode
nmap <leader><CR> i<CR><Esc>=%`^
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ## Operations with custom “text-objects”
" % - custom match from the line start to the match end.
nnoremap <leader>vv ^v%
nnoremap <leader>yy ^y%
nnoremap <leader>dd ^v%dkJ+
nnoremap <leader>cc ^c%
nmap <leader>== <leader>vv=
nmap <leader>zf <leader>vvzf
nnoremap <leader>J} ^%-J``
nmap <leader>JJ J<leader>==
nmap <leader>J, A,<Esc><leader>JJ
nmap <leader>J< <leader>J,
nmap <leader>V <Action>(EditorCodeBlockEndWithSelection)
nmap <leader>D <leader>V<Action>($Delete)
nmap <leader>C i<Action>(EditorCodeBlockEndWithSelection)<Action>($Delete)
" s - Empty lines.
nnoremap <leader>ds gEjVWkkD
nmap <leader>cs <leader>d<Space>i
" , - the line until preceding comma.
nnoremap <leader>v, /.,\?$<CR>v?,$<CR>
nmap <leader>y, <leader>v,y
nmap <leader>d, <leader>v,d
nmap <leader>c, <leader>v,c
" s - SQL statement.
nmap <leader>vs <Action>(sql.SelectCurrentStatement)<Action>(EditorSelectWord)<Action>(EditorSelectWord)
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ## Editor actions
nmap <C-O> <Action>(Back)
nmap <C-I> <Action>(Forward)
imap <C-N> <Action>(HippieBackwardCompletion)
imap <C-P> <Action>(HippieCompletion)
nmap <leader>1 <Action>(SelectInProjectView)
nmap <leader>wp <Action>($LRU)
nmap <leader>wc <Action>(CloseProject)
nmap <leader>* <Action>(EditorSelectWord)<Action>(FindInPath)<Action>(EditorLeft)
vmap <leader>* <Action>(FindInPath)<Action>(EditorLeft)
nmap <leader>gd <Action>(FindUsages)
nmap cd <Action>(RenameElement)
nmap gD <Action>(FindUsages)
nmap gf <Action>(EditorSelectWord)<Action>(GotoFile)<Action>(EditorLeft)
vmap gf <Action>(GotoFile)<Action>(EditorLeft)
nmap [m <Action>(MethodUp)
nmap ]m <Action>(MethodDown)
nmap [d <Action>(GotoPrevElementUnderCaretUsage)
nmap ]d <Action>(GotoNextElementUnderCaretUsage)
nmap [c <Action>(VcsShowPrevChangeMarker)
nmap ]c <Action>(VcsShowNextChangeMarker)
vmap zf <Action>(CollapseSelection)<Esc>
command! Reload action IdeaVim.ReloadVimRc.reload
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ## Code helpers
" Clojure comment form
nmap gc. i#_<Esc>`^<Action>(ReformatCode)
" Simple column alignment by previous line
nnoremap <leader><Tab><Space> 20i<Space><Esc>`[<Up>W<Down>dw
nnoremap <leader><Tab>, ge20a,<Esc>`[l<Up>W<Down>hdwi<Space><Esc>`^
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ## VIM & IDE Shortcuts
sethandler <C-A> a:ide
sethandler <C-B> a:ide
sethandler <C-C> a:vim
sethandler <C-D> a:vim
sethandler <C-E> a:ide i:vim
sethandler <C-F> a:ide
sethandler <C-G> a:vim
sethandler <C-H> a:vim
sethandler <C-I> a:ide n:vim
sethandler <C-K> a:vim
sethandler <C-L> a:ide
sethandler <C-N> a:vim
sethandler <C-O> a:vim
sethandler <C-P> a:vim
sethandler <C-Q> a:ide n:vim
sethandler <C-R> a:ide i:vim
sethandler <C-S> a:ide
sethandler <C-U> a:vim
sethandler <C-V> a:ide
sethandler <C-W> a:ide i:vim
sethandler <C-X> a:ide
sethandler <C-Y> a:vim
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""