-
Notifications
You must be signed in to change notification settings - Fork 1
/
_gvimrc
391 lines (322 loc) · 9.66 KB
/
_gvimrc
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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
" VIM Settings for Sam
" --------------------------------------------------
"
"
" Functions
"
"
" --------------------------------------------------
" __________________________________________________
" / Redir Messages \ {{{
function! RedirMessages(msgcmd, destcmd)
"
" Captures the output generated by executing a:msgcmd, then places this
" output in the current buffer.
"
" If the a:destcmd parameter is not empty, a:destcmd is executed
" before the output is put into the buffer. This can be used to open a
" new window, new tab, etc., before :put'ing the output into the
" destination buffer.
"
" Examples:
"
" " Insert the output of :registers into the current buffer.
" call RedirMessages('registers', '')
"
" " Output :registers into the buffer of a new window.
" call RedirMessages('registers', 'new')
"
" " Output :registers into a new vertically-split window.
" call RedirMessages('registers', 'vnew')
"
" " Output :registers to a new tab.
" call RedirMessages('registers', 'tabnew')
"
" Commands for common cases are defined immediately after the
" function; see below.
"
" Redirect messages to a variable.
"
redir => message
" Execute the specified Ex command, capturing any messages
" that it generates into the message variable.
"
silent execute a:msgcmd
" Turn off redirection.
"
redir END
" If a destination-generating command was specified, execute it to
" open the destination. (This is usually something like :tabnew or
" :new, but can be any Ex command.)
"
" If no command is provided, output will be placed in the current
" buffer.
"
if strlen(a:destcmd) " destcmd is not an empty string
silent execute a:destcmd
endif
" Place the messages in the destination buffer.
"
silent put=message
endfunction
" Create commands to make RedirMessages() easier to use interactively.
" Here are some examples of their use:
"
" :BufMessage registers
" :WinMessage ls
" :TabMessage echo "Key mappings for Control+A:" | map <C-A>
"
command! -nargs=+ -complete=command BufMessage call RedirMessages(<q-args>, '' )
command! -nargs=+ -complete=command WinMessage call RedirMessages(<q-args>, 'new' )
command! -nargs=+ -complete=command TabMessage call RedirMessages(<q-args>, 'tabnew' )
" \__________________________________________________/ }}}
" --------------------------------------------------
"
"
" Settings & Macros
"
"
" --------------------------------------------------
" __________________________________________________
" / General Settings \ {{{
" Disable the toolbar
:set guioptions-=T
" Follow current file
:set autochdir
" \__________________________________________________/ }}}
" __________________________________________________
" / Code cleanliness \ {{{
:filetype plugin on
:syntax enable
" Don't extend comments on newline
":au FileType * setl fo-=cro
" Tab spaces
:set tabstop=4
" This line is indented <num> spaces
:set shiftwidth=4
:set autoindent
" Set line numbering
:set number
" Set right-margin
:set cc=120
":highlight OverLength ctermbg=darkred ctermfg=white guibg=#FFD9D9
":match OverLength /\%81v.\+/
" Allow folding
:set foldmethod=marker
" Disable wrapping by default
:set nowrap
":set textwidth=0
":let g:leave_my_textwidth_alone = 1
" Configure Vim to move the cursor to the end of the
" previous line, when the left arrow key is pressed
" and the cursor is currently at the beginning of a
" line
:set whichwrap+=<>[]
" Highlite the current line
:set cursorline
" My font
:set guifont=Courier\ New,9
" \__________________________________________________/ }}}
" __________________________________________________
" / Hotkeys \ {{{
" Make arrow keys navigate in wrapped paragraphs
"nnoremap <Down> gj
"inoremap <Down> <C-\><C-o>gj
"vnoremap <Down> gj
"vnoremap <S-Down> gj
"
"nnoremap <Up> gk
"inoremap <Up> <C-\><C-o>gk
"vnoremap <Up> gk
"vnoremap <S-Up> gk
" <Ctrl-l> redraws the screen and removes any search highlighting.
nnoremap <silent> <C-l> :set invhlsearch<CR><C-l>
" Map Command+W to close document
if has("mac")
nnoremap <D-w> :q<CR>
inoremap <D-w> <C-o>:q<CR>
vnoremap <D-w> :q<CR>
cnoremap <D-w> <ESC>:<CR>
endif
" Backspace key
:set bs=2
" Map CTRL-S to save
nnoremap <C-s> :write<CR>
cnoremap <C-s> <Esc>:write<CR>
inoremap <C-s> <Esc>:write<CR>a
" Map CTRL-Z to undo
nnoremap <C-z> :undo<CR>
cnoremap <C-z> <Esc>:undo<CR>
inoremap <C-z> <Esc>:undo<CR>a
" Map CTRL+Backspace to delete word (backward)
inoremap <C-BS> <C-w>
cnoremap <C-BS> <C-w>
" Map CTRL+Space to word completion
inoremap <C-Space> <C-n>
" Map CTRL+Delete to delete word (forward)
inoremap <C-Del> <C-o>dw
" Map SHIFT+arrows to extend selection
" - Up
nmap <S-Up> v<Up>
imap <S-Up> <C-\><C-o>v<Up>
vmap <S-Up> <Up>
" - Down
nmap <S-Down> v<Down>
imap <S-Down> <C-o>v<Down>
vmap <S-Down> <Down>
" - Right
nmap <S-Right> v
imap <S-Right> <C-o>v
vmap <S-Right> l
vmap <Right> <Esc><Right>
" - Left
nmap <S-Left> v<Left>
imap <S-Left> <C-o>v
vmap <S-Left> h
vmap <Left> <Esc><Left>
" Map SHIFT+CTRL+arrows to extend selection
inoremap <CS-Right> <C-o>v<C-Right>
inoremap <CS-Left> <C-o>v<C-Left>
" Map SHIFT+HOME,END
" - Home
nnoremap <S-Home> v<Home>
inoremap <S-Home> <C-o>v<Home>
" - End
nnoremap <S-End> v<End>
inoremap <S-End> <C-o>v<End>
" Copy and paste
" - Ctrl+INS = Copy
vnoremap <C-Ins> y
" - Shift+INS = Paste
vnoremap <S-Ins> <Esc><Esc>p
nnoremap <S-Ins> <Left>p
inoremap <S-Ins> <Left><C-o>p
" Map <F8> to make
nnoremap <F8> :wa<CR>:make<CR>
inoremap <F8> <C-o>:wa<CR><C-o>:make<CR>
" \__________________________________________________/ }}}
" __________________________________________________
" / Mac Hotkeys \ {{{
" Mac Hotkeys
if has("mac")
" Map CMD+[ to Previous and CMD+] to Next
nnoremap <D-[> :cprev<CR>
inoremap <D-[> <C-o>:cprev<CR>
vnoremap <D-[> :cprev<CR>
cnoremap <D-[> <ESC>:cprev<CR>
nnoremap <D-]> :cnext<CR>
inoremap <D-]> <C-o>:cnext<CR>
vnoremap <D-]> :cnext<CR>
cnoremap <D-]> <ESC>:cnext<CR>
" Map CMD+Right to END
inoremap <D-Right> <END>
" Map ALT+Backspace to delete previous word
inoremap <M-BS> <C-\><C-o>db
nnoremap <M-BS> a<C-\><C-o>db
" Map CMD+Shift+Right to select until end
nnoremap <D-S-Right> v<End>
inoremap <D-S-Right> <C-\><C-o>v<End>
vnoremap <D-S-Right> <End>
" Map Opt+Shift+Left to select previous word
nnoremap <M-S-Left> vb
inoremap <M-S-Left> <C-o>vb
vnoremap <M-S-Left> b
" Map Opt+Shift+Right to select next word
nnoremap <M-S-Right> vw
inoremap <M-S-Right> <C-o>vw
vnoremap <M-S-Right> w
" Map Ctrl+R to :source %
autocmd FileType vim vnoremap <D-r> :source %<CR>
autocmd FileType vim nnoremap <D-r> :source %<CR>
autocmd FileType vim inoremap <D-r> <C-\><C-o>:source %<CR>
autocmd FileType vim cnoremap <D-r> <Esc>:source %<CR>
endif
" \__________________________________________________/ }}}
" __________________________________________________
" / Eclipse Keybindings \ {{{
" Map SHIFT+CR to END,CR
nnoremap <S-CR> o
inoremap <S-CR> <C-o>o
vnoremap <S-CR> <Esc><Esc>o
nnoremap <CS-CR> O
inoremap <CS-CR> <C-o>O
vnoremap <CS-CR> <Esc><Esc>O
" Map C-D to delete line
nnoremap <C-d> dd
inoremap <C-d> <C-o>dd
vnoremap <C-d> :delete<CR>
" Map M-Down to move line
nnoremap <M-DOWN> :move +1<CR>
nnoremap <M-UP> :move -2<CR>
inoremap <M-DOWN> <C-o>:move +1<CR>
inoremap <M-UP> <C-o>:move -2<CR>
vnoremap <M-DOWN> :move '>+1<CR>gv
vnoremap <M-UP> :move -2<CR>gv
" Shift + Tab should outdent
inoremap <S-Tab> <C-o><<CR>
vnoremap <Tab> >gv
vnoremap <S-Tab> <gv
" Map C-J to join lines
nnoremap <D-j>
\$
\:let oldCursor=[line("."), col(".")]<CR>
\:join<CR>
\:call cursor(oldCursor[0], oldCursor[1])<CR>
imap <D-j> <ESC><D-j>a
if has("mac")
" Map C-D to delete line
nnoremap <D-d> dd
inoremap <D-d> <C-o>dd
vnoremap <D-d> :delete<CR>
" Map CTRL+SHIFT+CR to HOME, CR
nnoremap <DS-CR> O
inoremap <DS-CR> <C-o>O
vnoremap <DS-CR> <Esc><Esc>O
" Map CM-Down to clone line
nnoremap <DM-DOWN> :copy +0<CR>
inoremap <DM-DOWN> <C-o>:copy +0<CR>
vnoremap <DM-DOWN> :copy +0<CR>gv
" Map CM-Up to clone line
nnoremap <DM-UP> :copy -1<CR>
inoremap <DM-UP> <C-o>:copy -1<CR>
vnoremap <DM-UP> :copy -1<CR>gv
" Map CMD+Shift+R to Find Files
else
" Map CM-Down to clone line
nnoremap <CM-DOWN> :copy +0<CR>
nnoremap <CM-UP> :copy -1<CR>
inoremap <CM-DOWN> <C-o>:copy +0<CR>
inoremap <CM-UP> <C-o>:copy -1<CR>
vnoremap <CM-DOWN> :copy '>+0<CR>gv
vnoremap <CM-UP> :copy -1<CR>gv
endif
" }}}
" --------------------------------------------------
"
"
" Plugins
"
"
" --------------------------------------------------
" __________________________________________________
" / Align plugin \ {{{
" I actually don't know what these commands do, I
" just put them in here because I was following
" instructions
:set nocp
:filetype plugin on
" \__________________________________________________/ }}}
" __________________________________________________
" / Fuzzy Finder \ {{{
inoremap <D-R> :FufCoverageFile<CR>
nnoremap <D-R> :FufCoverageFile<CR>
vnoremap <D-R> :FufCoverageFile<CR>
" \__________________________________________________/ }}}
" __________________________________________________
" / snipMate \ {{{
command! SnipMateReloadSnippets :SnipMateOpenSnippetFiles
" \__________________________________________________/ }}}
" __________________________________________________
" / VTreeExplorer \ {{{
" No settings as of yet
" \__________________________________________________/ }}}