forked from tony/vim-config-framework
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathkeymappings.vim
248 lines (168 loc) · 5.78 KB
/
keymappings.vim
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
" Map leader and localleader key to comma
let mapleader = ","
let g:mapleader = ","
let maplocalleader = ","
let g:maplocalleader = ","
" <Leader>2: Toggle Tagbar
nnoremap <silent> <Leader>2 :TagbarToggle<cr>
nnoremap <silent><leader>3 :call Preserve("normal gg=G")<CR>
" <Leader>7: Toggle between paste mode
nnoremap <silent> <Leader>7 :set paste!<cr>
" <Leader>7: Toggle between paste mode
nnoremap <silent> <Leader>7 :IndentGuidesToggle<cr>
" <Leader>8: Show line numbers
nnoremap <leader>8 :set number!<CR>
" <Leader>tab: Toggles NERDTree
nnoremap <leader><tab> :call NerdTreeFindPrevBuf()<cr>
let NERDTreeMapUpdir='-'
" <Leader>p: Copy the full path of the current file to the clipboard
nnoremap <silent> <Leader>p :let @+=expand("%:p")<cr>:echo "Copied current file
\ path '".expand("%:p")."' to clipboard"<cr>
" <Leader>d: Delete the current buffer
nnoremap <Leader><BS> :bdelete<CR>
nnoremap <Leader><Del> :bdelete<CR>
" Q: Closes the window
nnoremap Q :q<cr>
" Up Down Left Right resize splits
nnoremap <up> <c-w>+
nnoremap <down> <c-w>-
nnoremap <left> <c-w><
nnoremap <right> <c-w>>
"===============================================================================
" Visual Mode Ctrl Key Mappings
"===============================================================================
" Ctrl-c: Copy (works with system clipboard due to clipboard setting)
" vnoremap <c-c> y`]
" Ctrl-r: Easier search and replace
vnoremap <c-r> "hy:%s/<c-r>h//gc<left><left><left>
" Ctrl-s: Easier substitue
vnoremap <c-s> :s/\%V//g<left><left><left>
nnoremap <silent> <Leader>d :YcmCompleter GoToDefinition<cr>
nnoremap <silent> <Leader>g :YcmCompleter GoToDeclaration<cr>
nnoremap <silent> <Leader>p :bprev<cr>
nnoremap <silent> <Leader>n :bnext<cr>
" Map space to the prefix for Unite
" General fuzzy search
" nnoremap <silent> <space><space> :<C-u>CtrlPMixed<CR>
" nnoremap <silent> <space>o :<C-u>CtrlPBufTag<CR>
" nnoremap <silent> <space>b :<C-u>CtrlPBuffer<CR>
" nnoremap <silent> <space>m :<C-u>CtrlPMRU<CR>
"===============================================================================
" Fugitive
"===============================================================================
nnoremap <Leader>gb :Gblame<cr>
nnoremap <Leader>gc :Gcommit<cr>
nnoremap <Leader>gd :Gdiff<cr>
nnoremap <Leader>gp :Git push<cr>
nnoremap <Leader>gr :Gremove<cr>
nnoremap <Leader>gs :Gstatus<cr>
nnoremap <Leader>gw :Gwrite<cr>
" Quickly stage, commit, and push the current file. Useful for editing .vimrc
nnoremap <Leader>gg :Gwrite<cr>:Gcommit -m 'update'<cr>:Git push<cr>
"===============================================================================
" Visual Mode Key Mappings
"===============================================================================
" y: Yank and go to end of selection
xnoremap y y`]
" p: Paste in visual mode should not replace the default register with the
" deleted text
xnoremap p "_dP
" d: Delete into the blackhole register to not clobber the last yank. To 'cut',
" use 'x' instead
xnoremap d "_d
" \: Toggle comment
xmap \ <Leader>c<space>
" Enter: Highlight visual selections
xnoremap <silent> <CR> y:let @/ = @"<cr>:set hlsearch<cr>
" Backspace: Delete selected and go into insert mode
xnoremap <bs> c
" Space: QuickRun
xnoremap <space> :QuickRun<CR>
" <|>: Reselect visual block after indent
xnoremap < <gv
xnoremap > >gv
" .: repeats the last command on every line
xnoremap . :normal.<cr>
" @: repeats macro on every line
xnoremap @ :normal@
" Tab: Indent
xmap <Tab> >
" shift-tab: unindent
xmap <s-tab> <
"===============================================================================
"" NERDCommenter
"===============================================================================
"
"" Always leave a space between the comment character and the comment
let NERDSpaceDelims=1
" nnoremap <leader>e :call NerdTreeFindPrevBuf()<CR>
" nnoremap <leader>E :NERDTreeClose<CR>
" }}}
" Hey magellen, my dad works at a dealership man! {{{
" nnoremap <leader>t :TagbarOpen fj<cr>
" nnoremap <leader>T :TagbarClose<cr>
" }}}
" File Explorer {{{
" nnoremap <leader>x :Explore<CR>
" }}}
" File Explorer {{{
noremap <leader>x :Ex<CR>
" }}}
" Buffer Explorer {{{
" nnoremap <leader>b :CtrlPBuffer<CR>
" }}}
" Bexec {{{
" nnoremap <leader>r :Bexec<cr>
" nnoremap <leader>R :BexecCloseOut<cr>
" }}}
" Buffer Traversal {{{
" nnoremap <leader>p :bprevious<CR>
" nnoremap <leader>n :bnext<CR>
" nnoremap <leader>d :bdelete<CR>
" }}}
" Easy <esc> {{{
"imap <C-c> <esc>
"imap jk <esc>
"imap hl <esc>
" nnoremap <C-c> :if getwinvar(winnr("#"), "&pvw") <Bar> pclose <Bar> endif<CR>
" }}}
" Traversal
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" nnoremap <C-c> :close<CR>
" Moving
" No ctrl-shift sensitivity in vim (or case sensitivity with ascii at all?)
" nnoremap <C-S-h> <C-w>H
" nnoremap <C-S-j> <C-w>J
" nnoremap <C-S-k> <C-w>K
" nnoremap <C-S-l> <C-w>L
" Splitting
nnoremap <C-n> :SplitWindow<CR>
" nnoremap <C-Space> :ChangeLayout<CR>
" }}}
function! g:my_open_explorer_command()
return printf(":\<C-u>VimFilerBufferDir -buffer-name=%s -split -auto-cd -toggle -no-quit -winwidth=%s\<CR>",
\ g:my_vimfiler_explorer_name,
\ g:my_vimfiler_winwidth)
endfunction
nnoremap <expr><F2> g:my_open_explorer_command()
autocmd MyAutoCmd User PluginScratchInitializeAfter
\ call s:on_User_plugin_scratch_initialize_after()
function! s:on_User_plugin_scratch_initialize_after()
map <buffer> <CR> <Plug>(scratch-evaluate!)
endfunction
" Tabpage navigation
nnoremap th :tabfirst<CR>
nnoremap tk :tabnext<CR>
nnoremap tj :tabprev<CR>
nnoremap tl :tablast<CR>
nnoremap tt :tabedit<Space>
nnoremap tn :tabnext<Space>
nnoremap tm :tabm<Space>
nnoremap tx :tabclose<CR>
" Alternatively use
" "nnoremap th :tabnext<CR>
" "nnoremap tl :tabprev<CR>
" "nnoremap tn :tabnew<CR>