-
Notifications
You must be signed in to change notification settings - Fork 0
/
ideavimrc
211 lines (173 loc) · 4.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
" Plugin
set ideajoin
set easymotion
set surround
set multiple-cursors
set commentary
set NERDTree
set quickscope
set argtextobj
set textobj-indent
set highlightedyank
" set leader to space
let mapleader=' '
" some basic configuration"
set hlsearch
set incsearch
set ignorecase
set smartcase
set showmode
set number
set relativenumber
set scrolloff=3
set history=100000
set clipboard+=unnamed
" clear the highlighted search result
nnoremap <Leader>, :nohlsearch<CR>
" Quit normal mode
nnoremap <Leader>q :q<CR>
nnoremap <Leader>Q :qa!<CR>
" Insert mode shortcut
inoremap <C-h> <Left>
inoremap <C-j> <Down>
inoremap <C-k> <Up>
inoremap <C-l> <Right>
inoremap <C-a> <Home>
inoremap <C-e> <End>
inoremap <C-d> <Delete>
" nnoremap L l
" nnoremap H h
" nnoremap l w
" nnoremap h b
" Quit insert mode
inoremap jj <Esc>
inoremap jk <Esc>
" Quit visual mode
vnoremap v <Esc>
" Move to the start of line
" nnoremap H ^
" Move to the end of line
" nnoremap L $
" Redo
nnoremap U <C-r>
" Yank to the end of line
nnoremap Y y$
nnoremap 0 ^
nnoremap J mzJ`z
" quit ==> close current window
nnoremap <Leader>q <C-W>w
" Window operation
nnoremap <Leader>ww <C-W>w
nnoremap <Leader>wd <C-W>c
" split horizontal
nnoremap <Leader>ws <C-W>s
nnoremap <Leader>w- <C-W>s
" split vertical
nnoremap <Leader>wv <C-W>v
nnoremap <Leader>w\ <C-W>v
" Switch window
nnoremap <C-j> <C-W>j
nnoremap <C-k> <C-W>k
nnoremap <C-h> <C-W>h
nnoremap <C-l> <C-W>l
" Tab operation
nnoremap <Tab> gt
nnoremap <S-Tab> gT
" Move half page faster and center
nnoremap <C-d> <C-d>zz
nnoremap <C-u> <C-u>zz
" Search will center on the line it's found in
nnoremap n nzzzv
nnoremap N Nzzzv
nnoremap # #zz
nnoremap * *zz
nnoremap g; g;zz
" Whatever you delete, make it go away
nnoremap c "_c
nnoremap C "_C
nnoremap x "_x
nnoremap X "_X
xnoremap c "_c
xnoremap C "_C
xnoremap x "_x
xnoremap X "_X
" Mapping Alt + jk to move line up or down
" Ref https://vim.fandom.com/wiki/Moving_lines_up_or_down
nnoremap <A-j> :m .+1<CR>==
nnoremap <A-k> :m .-2<CR>==
inoremap <A-j> <Esc>:m .+1<CR>==gi
inoremap <A-k> <Esc>:m .-2<CR>==gi
vnoremap <A-j> :m '>+1<CR>gv=gv
vnoremap <A-k> :m '<-2<CR>gv=gv
" ==================================================
" Show all the provided actions via `:actionlist`
" ==================================================
" built in search looks better
" nnoremap / :action Find<CR>
" but preserve ideavim search
" nnoremap <Leader>/ /
" close other editor
nnoremap <Leader>co :action CloseAllEditorsButActive<CR>
nnoremap <Leader>cv :action ChangeView<CR>
nnoremap <Leader>pm :action ShowPopupMenu<CR>
nnoremap <C-z> :action ToggleDistractionFreeMode<CR>
" for debugging
nnoremap <Leader>db :action ToggleLineBreakpoint<CR>
nnoremap <Leader>dv :action ViewBreakpoints<CR
nnoremap <Leader>dc :action ChooseDebugConfiguration<CR>
" for running service
nnoremap <Leader>rC :action RunToCursor<CR>
nnoremap <Leader>rc :action ChooseRunConfiguration<CR>
nnoremap <Leader>rr :action Rerun<CR>
nnoremap <Leader>rs :action Stop<CR>
nnoremap <Leader>rf :action RenameFile<CR>
" Git
nnoremap <Leader>rh :action Vcs.RollbackChangedLines<CR>
nnoremap <Leader>ga :action Annotate<CR>
nnoremap <Leader>gb :action GitToolBox.BlameDetails<CR>
nnoremap <Leader>gd :action Compare.Selected<CR>
" project search
nnoremap <Leader>fe :action SearchEverywhere<CR>
nnoremap <Leader>fa :action GotoAction<CR>
nnoremap <Leader>fb :action FileStructurePopup<CR>
nnoremap <Leader>fc :action GotoClass<CR>
nnoremap <Leader>ff :action GotoFile<CR>
nnoremap <Leader>fp :action ShowFilePath<CR>
nnoremap <Leader>fu :action FindUsages<CR>
nnoremap <Leader>fs :action GotoSymbol<CR>
nnoremap <Leader>fdb :action GotoDatabaseObject<CR>
" LSP config
nnoremap gd :action GotoDeclaration<CR>
nnoremap gi :action GotoImplementation<CR>
nnoremap gt :action GotoTest<CR>
nnoremap gb :action Back<CR>
nnoremap gf :action Forward<CR>
nnoremap <Leader>re :action RenameElement<CR>
" Terminal
nnoremap <Leader>t :action ActivateTerminalToolWindow<CR>
nnoremap <Leader>oi :action OptimizeImports<CR>
nnoremap [d :action GotoPreviousError<CR>
nnoremap ]d :action GotoNextError<CR>
nnoremap [c :action VcsShowPrevChangeMarker<CR>
nnoremap ]c :action VcsShowNextChangeMarker<CR>
nnoremap [[ :action MethodUp<CR>
nnoremap ]] :action MethodDown<CR>
nnoremap <Leader>? :action GotoAction<CR>
" ===================================="
" ==================================================
" Plugin mapping: NERDTree
" https://github.com/JetBrains/ideavim/wiki/NERDTree-support
" ==================================================
" j/k: Go up and down.
" q: Close the project pane.
" P: Jump to the root node.
" o: Open file or directory.
" go: Open file but focus on the project pane.
" s: Open selected file in a new vertical split.
map <C-n> :NERDTreeToggle<CR>
map <Leader>e :NERDTreeFind<CR>
" ==================================================
" Plugin mapping: EasyMotion
" ==================================================
map <Leader>J <Plug>(easymotion-s)
map <Leader>j <Plug>(easymotion-f)