-
Notifications
You must be signed in to change notification settings - Fork 7
/
ideavimrc
191 lines (139 loc) · 4.45 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
" A config for IdeaVim that borrows heavily from Spacemacs key bindings.
let mapleader = " "
" Settings
" ========
" See
" https://github.com/JetBrains/ideavim/blob/master/doc/set-commands.md
" for details
" Use clipboard for yank.
set clipboard-=unnamed
set clipboard+=unnamed
set clipboard+=ideaput
" Highlight all search matches.
set hlsearch
" Show where search pattern typed so far matches
set incsearch
" Store 1000 entries of ":" commands and search patterns.
set history=1000
" Time to wait for a mapped key sequence.
set timeoutlen=400
" Ignore case in search patterns.
set ignorecase
" Override the 'ignorecase' option if the search pattern contains upper
" case characters.
set smartcase
" Vim Surround
set surround
set visualbell
set noerrorbell
" IDE Actions
" ===========
nnoremap <leader><Space> :action GotoAction<CR>
nnoremap <leader>c :action GotoClass<CR>
nnoremap <leader>ff :action GotoFile<CR>
nnoremap <leader>ft :action ActivateProjectToolWindow<CR>
nnoremap <leader>bb :action RecentFiles<CR>
nnoremap <leader>bi :action ActivateStructureToolWindow<CR>
nnoremap <leader>bu :action ReopenClosedTab<CR>
nnoremap <leader>' :action ActivateTerminalToolWindow<CR>
" ' <- Fix syntax highlighting in emacs.
nnoremap gd :action GotoDeclaration<cr>
nnoremap gh :action QuickJavaDoc<CR>
nnoremap gs :action GotoSymbol<cr>
nnoremap <leader>bp :action FileStructurePopup<cr>
nnoremap <leader>e :action ShowErrorDescription<cr>
nnoremap ,= :action ReformatCode<CR>
nnoremap <c-o> :action Back<cr>
nnoremap <c-i> :action Forward<cr>
" Reload .ideavimrc
nnoremap <Space>fer :source ~/.ideavimrc<CR>
" Movement
" ========
" page movement
nnoremap <C-j> <PageDown>
nnoremap <C-k> <PageUp>
" five lines
nnoremap J 5j
vnoremap J 5j
nnoremap K 5k
vnoremap K 5k
" beginning and end of line
nnoremap H ^
vnoremap H ^
nnoremap L $
vnoremap L $
nmap <c-o> :action Back<cr>
nmap <c-i> :action Forward<cr>
" Window Management
" =================
" move between adjacent windows
nnoremap <leader>wh <c-w>h
nnoremap <leader>wj <c-w>j
nnoremap <leader>wk <c-w>k
nnoremap <leader>wl <c-w>l
" horizontally split windows
nnoremap <leader>w- <c-W>s
" vertically split windows
nnoremap <leader>w/ <C-W>v
" maximize current window
nnoremap <leader>wm :action HideAllWindows<cr>
" close current window
nnoremap <leader>wd <C-W>c
" Editing
" =======
" Save file - yes, this is reduntant but it's so ingrained in my muscle memory,
" that we might as well make it do something.
nnoremap <Space>fs :w<CR>
" Copy from point to end of line.
nnoremap Y y$
" Join the line below with the current line.
nnoremap gj :join<CR>
" Fill Paragraph
nmap gq :action com.andrewbrookins.idea.wrap.WrapParagraphAction<CR>
" Navigation
" ==========
nnoremap <Leader>pf :action GotoFile<CR>
nnoremap <Leader>pc :action GotoClass<CR>
nnoremap gh :action QuickJavaDoc<CR>
" Find Usages
nnoremap <Leader>mu :action FindUsages<CR>
nnoremap <Leader>ga :action GotoAction<CR>
" Collapse and Expand Regions
nnoremap za :action CollapseRegionRecursively<CR>
nnoremap zC :action CollapseRegionRecursively<CR>
nnoremap zO :action ExpandRegionRecursively<CR>
nnoremap zm :action CollapseAllRegions<CR>
nnoremap zr :action ExpandAllRegions<CR>
" Refactoring
" ===========
" Renaming
nnoremap <leader>mr :action RenameElement<CR>
nnoremap <leader>m= :action ReformatCode<CR>
nnoremap <leader>mc :action IntroduceConstant<CR>
nnoremap <leader>mf :action IntroduceField<CR>
nnoremap <leader>mp :action IntroduceParameter<CR>
nnoremap <leader>mv :action IntroduceVariable<CR>
" Version Control
" ===============
nnoremap <leader>gs :action Vcs.QuickListPopupAction<CR>
nnoremap <leader>gS :action ActivateVersionControlToolWindow<CR>
nnoremap <leader>gb :action Annotate<CR>
" FIXME - how do I show the log?
" nnoremap <Space>gl :action ShowHistory<CR>
" Searching
" =========
nnoremap <leader>sp :action FindInPath<CR>
vnoremap <leader>sp :<Backspace><Backspace><Backspace><Backspace><Backspace>action FindInPath<CR>
" Clear search highlighting.
nnoremap <Space>sc :nohlsearch<CR>
" Bazel
" =====
nnoremap <leader>pb :action Blaze.OpenCorrespondingBuildFile<CR>
nnoremap <leader>pp :action Blaze.EditLocalProjectView<CR>
" Ace Jump
" ========
" https://github.com/johnlindquist/AceJump
map <Space>jw :action AceAction<CR>
map <Space>jj :action AceTargetAction<CR>
map <Space>jl :action AceLineAction<CR>
:echo ".ideavimrc reloaded"