-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.vimrc
687 lines (619 loc) · 25.8 KB
/
.vimrc
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
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
execute pathogen#infect()
set encoding=utf-8
set nocompatible
let mapleader=","
if $COLORTERM == 'gnome-terminal'
set t_Co=256
endif
let g:gruvbox_italic=0
set background=dark
colorscheme gruvbox
filetype on
filetype plugin on
if !exists("syntax_on")
syntax on
endif
" Remove menubar
set guioptions-=m
set guioptions-=T
set guicursor+=a:blinkon0
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set autoindent
set smartindent
set number
set relativenumber
" Disable irritating sound
set vb
set pastetoggle=<F10>
set mouse=a
"if &term =~ '^screen'
" " tmux knows the extended mouse mode
" set ttymouse=xterm2
"endif
if has("mouse_sgr")
set ttymouse=sgr
else
set ttymouse=xterm2
end
hi Normal ctermbg=none
highlight NonText ctermbg=none
" Search and map handling
nnoremap <C-q> :noh<return><esc>
set ignorecase
set hlsearch
" delete without yanking
nnoremap <leader>d "_d
vnoremap <leader>d "_d
" replace currently selected text with default register
" without yanking it
vnoremap <leader>p "_dP
map vadl $v_o$hd"_dd<esc>
map vayl $v_o$hy<esc>
map val $v_o$h
map vak v0o$h
map vaj v$h
map vaf {jwv}k$h
map vadj v$hd<esc>
map vaop o<esc>Vp
map vaoo o<C-v><esc>
map vaip op
" Make vim handle windowing stuff
set guioptions-=a
set guifont=Monospace\ 9
set guitablabel=\[%N\]\ %t\ %M
" Make word wrapping and selection work more sane
"behave mswin
" Multi cursor settings
let g:multi_cursor_exit_from_insert_mode=0
map <C-w>v :vsplit<cr><C-w>l
map <C-w>s :split<cr><C-w>j
map <C-w>\ <C-w><C-_><C-w><C-\|>
map <C-w><Up> :res +4<CR>
map <C-w><Down> :res -4<CR>
map <C-w><Left> :vertical resize -4<CR>
map <C-w><Right> :vertical resize +4<CR>
imap <C-v> <F10><C-r>"<F10>
"xclip stuff
vmap "+y :!xclip -f -selection clipboard<cr>u
map "+p :exec "set paste" \| exec "r!xclip -o -selection clipboard" \| exec "set nopaste"<cr>
" Tab Handling and navigation
nnoremap <silent> <C-W>t :tabnew<CR>
nnoremap <silent> <C-W>e :tabclose<CR>
nnoremap <silent> <C-W>u :tabNext<CR>
map <A-1> 1gt
map yy1 1gt
imap yy1 <Esc>1gt
vmap yy1 1gt
map <A-2> 2gt
map yy2 2gt
imap yy2 <Esc>2gt
vmap yy2 2gt
map <A-3> 3gt
map yy3 3gt
imap yy3 <Esc>3gt
vmap yy3 3gt
map <A-4> 4gt
map yy4 4gt
imap yy4 <Esc>4gt
vmap yy4 4gt
map <A-5> 5gt
map yy5 5gt
imap yy5 <Esc>5gt
vmap yy5 5gt
map <A-6> 6gt
map yy6 6gt
imap yy6 <Esc>6gt
vmap yy6 6gt
map <A-7> 7gt
map yy7 7gt
imap yy7 <Esc>7gt
vmap yy7 7gt
map <A-8> 8gt
map yy8 8gt
imap yy8 <Esc>8gt
vmap yy8 8gt
map <A-9> 9gt
map yy9 9gt
imap yy9 <Esc>9gt
vmap yy9 9gt
" Remap escape to something closer to core in insert mode
imap jj <Esc>
" Save mappings
map <C-s> :w<cr>
imap <C-s> <Esc>:w<cr>
map <C-S-s> :wa<cr>
imap <C-S-s> <Esc>:wa<cr>
let delimitMate_expand_cr = 1
filetype indent plugin on
function! Multiple_cursors_before()
DelimitMateOff
let delimitMate_expand_cr = 0
filetype indent plugin off
set noexpandtab
set noautoindent
set nosmartindent
endfunction
function! Multiple_cursors_after()
DelimitMateOn
let delimitMate_expand_cr = 1
filetype indent plugin on
set expandtab
set autoindent
set smartindent
endfunction
" Find mapping
nmap <space> /
" Make Ctrl+l, insert ; at end of line
nmap <C-l> :<C-u>call MyAppendToEnd(";")<CR>
imap <C-l> <Esc>:<C-u>call MyAppendToEnd(";")<CR>a
nmap <C-k> $a
imap <C-k> <Esc>$a
imap <C-f>0 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>o}
imap <C-f>1 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jg0>>o}
imap <C-f>2 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv1jg0><Esc>1jo}
imap <C-f>3 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv2jg0><Esc>2jo}
imap <C-f>4 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv3jg0><Esc>3jo}
imap <C-f>5 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv4jg0><Esc>4jo}
imap <C-f>6 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv5jg0><Esc>5jo}
imap <C-f>7 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv6jg0><Esc>6jo}
imap <C-f>8 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv7jg0><Esc>7jo}
imap <C-f>9 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv8jg0><Esc>8jo}
imap <C-f>10 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv9jg0><Esc>9jo}
imap <C-f>11 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv10jg0><Esc>10jo}
imap <C-f>12 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv11jg0><Esc>11jo}
imap <C-f>13 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv12jg0><Esc>12jo}
imap <C-f>14 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv13jg0><Esc>13jo}
imap <C-f>15 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv14jg0><Esc>14jo}
imap <C-f>16 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv15jg0><Esc>15jo}
imap <C-f>17 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv16jg0><Esc>16jo}
imap <C-f>18 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv17jg0><Esc>17jo}
imap <C-f>19 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv18jg0><Esc>18jo}
imap <C-f>20 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv19jg0><Esc>19jo}
imap <C-f>21 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv20jg0><Esc>20jo}
imap <C-f>22 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv21jg0><Esc>21jo}
imap <C-f>23 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv22jg0><Esc>22jo}
imap <C-f>24 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv23jg0><Esc>23jo}
imap <C-f>25 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv24jg0><Esc>24jo}
imap <C-f>26 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv25jg0><Esc>25jo}
imap <C-f>27 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv26jg0><Esc>26jo}
imap <C-f>28 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv27jg0><Esc>27jo}
imap <C-f>29 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv28jg0><Esc>28jo}
imap <C-f>30 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv29jg0><Esc>29jo}
imap <C-f>31 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv30jg0><Esc>30jo}
imap <C-f>32 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv31jg0><Esc>31jo}
imap <C-f>33 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv32jg0><Esc>32jo}
imap <C-f>34 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv33jg0><Esc>33jo}
imap <C-f>35 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv34jg0><Esc>34jo}
imap <C-f>36 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv35jg0><Esc>35jo}
imap <C-f>37 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv36jg0><Esc>36jo}
imap <C-f>38 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv37jg0><Esc>37jo}
imap <C-f>39 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv38jg0><Esc>38jo}
imap <C-f>40 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv39jg0><Esc>39jo}
imap <C-f>41 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv40jg0><Esc>40jo}
imap <C-f>42 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv41jg0><Esc>41jo}
imap <C-f>43 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv42jg0><Esc>42jo}
imap <C-f>44 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv43jg0><Esc>43jo}
imap <C-f>45 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv44jg0><Esc>44jo}
imap <C-f>46 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv45jg0><Esc>45jo}
imap <C-f>47 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv46jg0><Esc>46jo}
imap <C-f>48 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv47jg0><Esc>47jo}
imap <C-f>49 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv48jg0><Esc>48jo}
imap <C-f>50 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv49jg0><Esc>49jo}
imap <C-f>51 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv50jg0><Esc>50jo}
imap <C-f>52 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv51jg0><Esc>51jo}
imap <C-f>53 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv52jg0><Esc>52jo}
imap <C-f>54 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv53jg0><Esc>53jo}
imap <C-f>55 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv54jg0><Esc>54jo}
imap <C-f>56 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv55jg0><Esc>55jo}
imap <C-f>57 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv56jg0><Esc>56jo}
imap <C-f>58 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv57jg0><Esc>57jo}
imap <C-f>59 <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv58jg0><Esc>58jo}
map <C-f>0 :<C-u>call MyAppendToEnd(" {")<CR>o}
map <C-f>1 :<C-u>call MyAppendToEnd(" {")<CR>jg0>>o}
map <C-f>2 :<C-u>call MyAppendToEnd(" {")<CR>jv1jg0><Esc>1jo}
map <C-f>3 :<C-u>call MyAppendToEnd(" {")<CR>jv2jg0><Esc>2jo}
map <C-f>4 :<C-u>call MyAppendToEnd(" {")<CR>jv3jg0><Esc>3jo}
map <C-f>5 :<C-u>call MyAppendToEnd(" {")<CR>jv4jg0><Esc>4jo}
map <C-f>6 :<C-u>call MyAppendToEnd(" {")<CR>jv5jg0><Esc>5jo}
map <C-f>7 :<C-u>call MyAppendToEnd(" {")<CR>jv6jg0><Esc>6jo}
map <C-f>8 :<C-u>call MyAppendToEnd(" {")<CR>jv7jg0><Esc>7jo}
map <C-f>9 :<C-u>call MyAppendToEnd(" {")<CR>jv8jg0><Esc>8jo}
map <C-f>10 :<C-u>call MyAppendToEnd(" {")<CR>jv9jg0><Esc>9jo}
map <C-f>11 :<C-u>call MyAppendToEnd(" {")<CR>jv10jg0><Esc>10jo}
map <C-f>12 :<C-u>call MyAppendToEnd(" {")<CR>jv11jg0><Esc>11jo}
map <C-f>13 :<C-u>call MyAppendToEnd(" {")<CR>jv12jg0><Esc>12jo}
map <C-f>14 :<C-u>call MyAppendToEnd(" {")<CR>jv13jg0><Esc>13jo}
map <C-f>15 :<C-u>call MyAppendToEnd(" {")<CR>jv14jg0><Esc>14jo}
map <C-f>16 :<C-u>call MyAppendToEnd(" {")<CR>jv15jg0><Esc>15jo}
map <C-f>17 :<C-u>call MyAppendToEnd(" {")<CR>jv16jg0><Esc>16jo}
map <C-f>18 :<C-u>call MyAppendToEnd(" {")<CR>jv17jg0><Esc>17jo}
map <C-f>19 :<C-u>call MyAppendToEnd(" {")<CR>jv18jg0><Esc>18jo}
map <C-f>20 :<C-u>call MyAppendToEnd(" {")<CR>jv19jg0><Esc>19jo}
map <C-f>21 :<C-u>call MyAppendToEnd(" {")<CR>jv20jg0><Esc>20jo}
map <C-f>22 :<C-u>call MyAppendToEnd(" {")<CR>jv21jg0><Esc>21jo}
map <C-f>23 :<C-u>call MyAppendToEnd(" {")<CR>jv22jg0><Esc>22jo}
map <C-f>24 :<C-u>call MyAppendToEnd(" {")<CR>jv23jg0><Esc>23jo}
map <C-f>25 :<C-u>call MyAppendToEnd(" {")<CR>jv24jg0><Esc>24jo}
map <C-f>26 :<C-u>call MyAppendToEnd(" {")<CR>jv25jg0><Esc>25jo}
map <C-f>27 :<C-u>call MyAppendToEnd(" {")<CR>jv26jg0><Esc>26jo}
map <C-f>28 :<C-u>call MyAppendToEnd(" {")<CR>jv27jg0><Esc>27jo}
map <C-f>29 :<C-u>call MyAppendToEnd(" {")<CR>jv28jg0><Esc>28jo}
map <C-f>30 :<C-u>call MyAppendToEnd(" {")<CR>jv29jg0><Esc>29jo}
map <C-f>31 :<C-u>call MyAppendToEnd(" {")<CR>jv30jg0><Esc>30jo}
map <C-f>32 :<C-u>call MyAppendToEnd(" {")<CR>jv31jg0><Esc>31jo}
map <C-f>33 :<C-u>call MyAppendToEnd(" {")<CR>jv32jg0><Esc>32jo}
map <C-f>34 :<C-u>call MyAppendToEnd(" {")<CR>jv33jg0><Esc>33jo}
map <C-f>35 :<C-u>call MyAppendToEnd(" {")<CR>jv34jg0><Esc>34jo}
map <C-f>36 :<C-u>call MyAppendToEnd(" {")<CR>jv35jg0><Esc>35jo}
map <C-f>37 :<C-u>call MyAppendToEnd(" {")<CR>jv36jg0><Esc>36jo}
map <C-f>38 :<C-u>call MyAppendToEnd(" {")<CR>jv37jg0><Esc>37jo}
map <C-f>39 :<C-u>call MyAppendToEnd(" {")<CR>jv38jg0><Esc>38jo}
map <C-f>40 :<C-u>call MyAppendToEnd(" {")<CR>jv39jg0><Esc>39jo}
map <C-f>41 :<C-u>call MyAppendToEnd(" {")<CR>jv40jg0><Esc>40jo}
map <C-f>42 :<C-u>call MyAppendToEnd(" {")<CR>jv41jg0><Esc>41jo}
map <C-f>43 :<C-u>call MyAppendToEnd(" {")<CR>jv42jg0><Esc>42jo}
map <C-f>44 :<C-u>call MyAppendToEnd(" {")<CR>jv43jg0><Esc>43jo}
map <C-f>45 :<C-u>call MyAppendToEnd(" {")<CR>jv44jg0><Esc>44jo}
map <C-f>46 :<C-u>call MyAppendToEnd(" {")<CR>jv45jg0><Esc>45jo}
map <C-f>47 :<C-u>call MyAppendToEnd(" {")<CR>jv46jg0><Esc>46jo}
map <C-f>48 :<C-u>call MyAppendToEnd(" {")<CR>jv47jg0><Esc>47jo}
map <C-f>49 :<C-u>call MyAppendToEnd(" {")<CR>jv48jg0><Esc>48jo}
map <C-f>50 :<C-u>call MyAppendToEnd(" {")<CR>jv49jg0><Esc>49jo}
map <C-f>51 :<C-u>call MyAppendToEnd(" {")<CR>jv50jg0><Esc>50jo}
map <C-f>52 :<C-u>call MyAppendToEnd(" {")<CR>jv51jg0><Esc>51jo}
map <C-f>53 :<C-u>call MyAppendToEnd(" {")<CR>jv52jg0><Esc>52jo}
map <C-f>54 :<C-u>call MyAppendToEnd(" {")<CR>jv53jg0><Esc>53jo}
map <C-f>55 :<C-u>call MyAppendToEnd(" {")<CR>jv54jg0><Esc>54jo}
map <C-f>56 :<C-u>call MyAppendToEnd(" {")<CR>jv55jg0><Esc>55jo}
map <C-f>57 :<C-u>call MyAppendToEnd(" {")<CR>jv56jg0><Esc>56jo}
map <C-f>58 :<C-u>call MyAppendToEnd(" {")<CR>jv57jg0><Esc>57jo}
map <C-f>59 :<C-u>call MyAppendToEnd(" {")<CR>jv58jg0><Esc>58jo}
imap <C-f>} <Esc>:<C-u>call MyAppendToEnd(" {")<CR>jv}g0><Esc>}o}
function! MyAppendToEnd(valueToAdd)
let ln = line('.')
let cl = col('.')
let text = getline('.')
call setline(ln,text . a:valueToAdd)
call cursor(ln,cl)
endfunction
" Make alt key work in terminal
let c='a'
while c <= 'z'
exec "set <A-".c.">=\e".c
exec "imap \e".c." <A-".c.">"
let c = nr2char(1+char2nr(c))
endw
set timeoutlen=1000 ttimeoutlen=0
vnoremap r "hy:%s/<C-r>h//gc<left><left><left>
vnoremap <C-r> h:s///g<left><left><left>
" backspace and cursor keys wrap to previous/next line
"set backspace=indent,eol,start whichwrap+=<,>,[,]
" backspace in Visual mode deletes selection
"vnoremap <BS> d
" Indent/Unindent
nmap <Tab> >>
nmap <S-Tab> a<C-d><Esc>
imap <S-Tab> <C-d>
vmap <silent> <Tab> :<C-u>call My_indent("v")<CR>
vmap <silent> <S-Tab> :<C-u>call My_unindent("v")<CR>
function! My_indent(mode)
normal gv
normal >
normal gv
endfunction
function! My_unindent(mode)
normal gv
normal <
normal gv
endfunction
set tabline=%!MyTabLine() " custom tab pages line
function! MyTabLine()
let s = '' " complete tabline goes here
" loop through each tab page
for t in range(tabpagenr('$'))
" set highlight
if t + 1 == tabpagenr()
let s .= '%#TabLineSel#'
else
let s .= '%#TabLine#'
endif
" set the tab page number (for mouse clicks)
let s .= '%' . (t + 1) . 'T'
let s .= ' '
" set page number string
let s .= t + 1 . ' '
" get buffer names and statuses
let n = '' "temp string for buffer names while we loop and check buftype
let m = 0 " &modified counter
let bc = len(tabpagebuflist(t + 1)) "counter to avoid last ' '
let tooLong = 0
let maxLength = 20
" loop through each buffer in a tab
for b in tabpagebuflist(t + 1)
if tooLong == 0
if len(n) < maxLength
" buffer types: quickfix gets a [Q], help gets [H]{base fname}
" others get 1dir/2dir/3dir/fname shortened to 1/2/3/fname
if getbufvar( b, "&buftype" ) == 'help'
let n .= '[H]' . fnamemodify( bufname(b), ':t:s/.txt$//' )
elseif getbufvar( b, "&buftype" ) == 'quickfix'
let n .= '[Q]'
else
"let n .= pathshorten(bufname(b))
"let n .= bufname(b)
let n .= fnamemodify(bufname(b), ':t')
endif
" check and ++ tab's &modified count
if getbufvar( b, "&modified" )
let m += 1
endif
" no final ' ' added...formatting looks better done later
if bc > 1
if len(n) < maxLength
let n .= ', '
endif
endif
let bc -= 1
else
let n .= ".."
let tooLong = 1
endif
endif
endfor
" add modified label [n+] where n pages in tab are modified
if m > 0
let s .= '[' . m . '+]'
endif
" select the highlighting for the buffer names
" my default highlighting only underlines the active tab
" buffer names.
if t + 1 == tabpagenr()
let s .= '%#TabLineSel#'
else
let s .= '%#TabLine#'
endif
" add buffer names
if n == ''
let s.= '[New]'
else
let s .= n
endif
" switch to no underlining and add final space to buffer list
let s .= ' '
endfor
" after the last tab fill with TabLineFill and reset tab page nr
let s .= '%#TabLineFill#%T'
" right-align the label to close the current tab page
if tabpagenr('$') > 1
let s .= '%=%#TabLineFill#%999Xclose'
endif
return s
endfunction
" OpenIDE commands
if has('win32')
map <C-S-j> :let x = system('oi set-to-foreground ContinuousTests "ContinuousTests Standalone Client"')$
imap <C-S-j> <Esc>:let x = system('oi set-to-foreground ContinuousTests "ContinuousTests Standalone Cli$
map <C-S-y> :let x = system('oi gototype')<cr>
imap <C-S-y> <Esc>:let x = system('oi gototype')<cr>
map <C-S-e> :let x = system('oi explore')<cr>
imap <C-S-e> <Esc>:let x = system('oi explore')<cr>
else
" Open IDE shortcuts
"map <C-S-y> :nbkey gototype<cr>
"imap <C-S-y> <Esc>:nbkey gototype<cr>
map <C-S-y> :let x = system("/home/ack/bin/OpenIDE/.OpenIDE/rscripts/tmux-editor-handler-files/typesearch-launcher")<cr>
imap <C-S-y> <Esc> :let x = system("/home/ack/bin/OpenIDE/.OpenIDE/rscripts/tmux-editor-handler-files/typesearch-launcher")<cr>
map <C-S-j> :nbkey autotest.net setfocus<cr>
imap <C-S-j> <Esc>:nbkey autotest.net setfocus<cr>
map <C-S-e> :nbkey explore<cr>
imap <C-S-e> <Esc>:nbkey explore<cr>
endif
imap <F5> <Esc>:!oi x run<cr>
map <F5> :!oi x run<cr>
map <A-o> :let x = system("oi codemodel publish \"complete-snippet\"")<cr>
map yyo :let x = system("oi codemodel publish \"complete-snippet\"")<cr>
map <C-h> :let x = system("oi codemodel publish \"." . &ft . " command tamper-at-caret\"")<cr>
inoremap <C-h> <Esc>:let x = system("oi codemodel publish \"." . &ft . " command tamper-at-caret\"")<cr>
map <A-g> :let x = system("oi codemodel publish \"." . &ft . " command navigate-at-caret\"")<cr>
map yyg :let x = system("oi codemodel publish \"." . &ft . " command navigate-at-caret\"")<cr>
map <A-l> :let x = system("oi codemodel publish \"." . &ft . " command command-at-caret\"")<cr>
map yyl :let x = system("oi codemodel publish \"." . &ft . " command command-at-caret\"")<cr>
map yyd :let x = system("oi codemodel publish \"." . &ft . " command go-to-definition\"")<cr>
map yyvd <C-w>v:let x = system("oi codemodel publish \"." . &ft . " command go-to-definition\"")<cr>
map yysd <C-w>s:let x = system("oi codemodel publish \"." . &ft . " command go-to-definition\"")<cr>
map yyd :let x = system("oi codemodel publish \"." . &ft . " command go-to-definition\"")<cr>
map <A-S-y> :let x = system("oi codemodel publish \"gototype-extension\"")<cr>
map <A-r> :let x = system("oi codemodel publish \"evaluate-at-caret\"")<cr>
map yyr :let x = system("oi codemodel publish \"evaluate-at-caret\"")<cr>
map <A-n> :let x = system("oi codemodel publish \"." . &ft . " command new-from-caret\"")<cr>
map yyn :let x = system("oi codemodel publish \"." . &ft . " command new-from-caret\"")<cr>
map <A-e> :let x = system("oi codemodel publish \"." . &ft . " command evaluate-file\"")<cr>
map 0e :let x = system("oi codemodel publish \"." . &ft . " command evaluate-file\"")<cr>
map <A-w>e :<C-u>call SendSelectionToOpenIDEAsFile("repl", "")<cr>
map yywe :<C-u>call SendSelectionToOpenIDEAsFile("repl", "")<cr>
map <A-w>r :<C-u>call SendSelectionToOpenIDEAsFile("repl","notappend")<cr>
map yywr :<C-u>call SendSelectionToOpenIDEAsFile("repl","notappend")<cr>
map <A-w>q :let x = system("oi codemodel publish \"." .&ft . " command repl 'clearOIRepl'\"")<cr>
map yywq :let x = system("oi codemodel publish \"." .&ft . " command repl 'clearOIRepl'\"")<cr>
map <A-f> :let x = system("oi codemodel publish \"." .&ft . " command find-interactive\"")<cr>
map yyf :let x = system("oi codemodel publish \"." .&ft . " command find-interactive\"")<cr>
map <A-f>a :let x = system("oi codemodel publish \"." .&ft . " command find-interactive-all\"")<cr>
map yyfa :let x = system("oi codemodel publish \"." .&ft . " command find-interactive-all\"")<cr>
map <A-f>y :let x = system("oi codemodel publish \"." .&ft . " command find-interactive-yml\"")<cr>
map yyfy :let x = system("oi codemodel publish \"." .&ft . " command find-interactive-yml\"")<cr>
map <A-f>yw :let x = system("oi codemodel publish \"." .&ft . " command find-interactive-word\"")<cr>
map yyfw :let x = system("oi codemodel publish \"." .&ft . " command find-interactive-word\"")<cr>
"map <C-p> :let x = system("/home/ack/bin/OpenIDE/.OpenIDE/rscripts/tmux-editor-handler-files/file-search-launcher")<cr>
"imap <C-p> <Esc> :let x = system("/home/ack/bin/OpenIDE/.OpenIDE/rscripts/tmux-editor-handler-files/file-search-launcher")<cr>
function! SendSelectionToOpenIDEAsFile(oiCmd,prefix)
let selection = s:get_visual_selection("||newline||")
let selection = s:strreplace(selection, "\"", "||q||")
let selection = s:strreplace(selection, "'", "||sq||")
let selection = s:strreplace(selection, "$", "||dollar||")
let cmdprefix = "||" . a:prefix . "||"
let cmdprefix = s:strreplace(cmdprefix, "||||", "")
let x = system("oi codemodel publish \"." .&ft . " command " . a:oiCmd . " '" . cmdprefix . selection . "'\"")
"system("oi codemodel publish \"." . &ft . " fromvim \"" . selection . "\"")
endfunction
func! s:strfind(s,find,start)
if type(a:find)==1
let l:i = a:start
while l:i<len(a:s)
if strpart(a:s,l:i,len(a:find))==a:find
return l:i
endif
let l:i+=1
endwhile
return -1
elseif type(a:find)==3
" a:find is a list
let l:i = a:start
while l:i<len(a:s)
let l:j=0
while l:j<len(a:find)
if strpart(a:s,l:i,len(a:find[l:j]))==a:find[l:j]
return [l:i,l:j]
endif
let l:j+=1
endwhile
let l:i+=1
endwhile
return [-1,-1]
endif
endfunc
func! s:strreplace(s,find,replace)
if len(a:find)==0
return a:s
endif
if type(a:find)==1 && type(a:replace)==1
let l:ret = a:s
let l:i = s:strfind(l:ret,a:find,0)
while l:i!=-1
let l:ret = strpart(l:ret,0,l:i).a:replace.strpart(l:ret,l:i+len(a:find))
let l:i = s:strfind(l:ret,a:find,l:i+len(a:replace))
endwhile
return l:ret
elseif type(a:find)==3 && type(a:replace)==3 && len(a:find)==len(a:replace)
let l:ret = a:s
let [l:i,l:j] = s:strfind(l:ret,a:find,0)
while l:i!=-1
let l:ret = strpart(l:ret,0,l:i).a:replace[l:j].strpart(l:ret,l:i+len(a:find[l:j]))
let [l:i,l:j] = s:strfind(l:ret,a:find,l:i+len(a:replace[l:j]))
endwhile
return l:ret
endif
endfunc
"here is a more exotic version of my original Kwbd script
"delete the buffer; keep windows; create a scratch buffer if no buffers left
function! s:Kwbd(kwbdStage)
if(a:kwbdStage == 1)
if(!buflisted(winbufnr(0)))
bd!
return
endif
let s:kwbdBufNum = bufnr("%")
let s:kwbdWinNum = winnr()
windo call s:Kwbd(2)
execute s:kwbdWinNum . 'wincmd w'
let s:buflistedLeft = 0
let s:bufFinalJump = 0
let l:nBufs = bufnr("$")
let l:i = 1
while(l:i <= l:nBufs)
if(l:i != s:kwbdBufNum)
if(buflisted(l:i))
let s:buflistedLeft = s:buflistedLeft + 1
else
if(bufexists(l:i) && !strlen(bufname(l:i)) && !s:bufFinalJump)
let s:bufFinalJump = l:i
endif
endif
endif
let l:i = l:i + 1
endwhile
if(!s:buflistedLeft)
if(s:bufFinalJump)
windo if(buflisted(winbufnr(0))) | execute "b! " . s:bufFinalJump | endif
else
enew
let l:newBuf = bufnr("%")
windo if(buflisted(winbufnr(0))) | execute "b! " . l:newBuf | endif
endif
execute s:kwbdWinNum . 'wincmd w'
endif
if(buflisted(s:kwbdBufNum) || s:kwbdBufNum == bufnr("%"))
execute "bd! " . s:kwbdBufNum
endif
if(!s:buflistedLeft)
set buflisted
set bufhidden=delete
set buftype=
setlocal noswapfile
endif
else
if(bufnr("%") == s:kwbdBufNum)
let prevbufvar = bufnr("#")
if(prevbufvar > 0 && buflisted(prevbufvar) && prevbufvar != s:kwbdBufNum)
b #
else
bn
endif
endif
endif
endfunction
" Creds to peterodding.com
function! s:get_visual_selection(separator)
" Why is this not a built-in Vim script function?!
let [lnum1, col1] = getpos("'<")[1:2]
let [lnum2, col2] = getpos("'>")[1:2]
let lines = getline(lnum1, lnum2)
let lines[-1] = lines[-1][: col2 - (&selection == 'inclusive' ? 1 : 2)]
let lines[0] = lines[0][col1 - 1:]
return join(lines, a:separator)
endfunction
command! Kwbd call s:Kwbd(1)
nnoremap <silent> <Plug>Kwbd :<C-u>Kwbd<CR>
" Delete buffer shortcut
nnoremap <silent> <C-w>d :close<CR>
nnoremap <silent> <C-w>d :bdelete<CR>
nnoremap <silent> <C-w>p :Kwbd<CR>
map <C-k><C-b> :NERDTreeToggle<CR>
map <C-k><C-h> :NERDTreeFocus<CR>
map <C-k><C-f> :NERDTreeFind<CR>
let g:NERDTreeWinSize=50
" enable line numbers
let NERDTreeShowLineNumbers=1
" make sure relative line numbers are used
autocmd FileType nerdtree setlocal relativenumber
map <C-x><C-x> <esc>:qa<cr>
map <C-x><C-x> :qa<cr>
set laststatus=2
map <Leader> <Plug>(easymotion-prefix)
map / <Plug>(easymotion-sn)
omap / <Plug>(easymotion-tn)
filetype plugin on
set omnifunc=syntaxcomplete#Complete
set statusline=%F%m%r%h%w\ %v:%l\ %L\ %p%%
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:SuperTabDefaultCompletionType = "<c-n>"
let g:fsharp_xbuild_path = "/usr/bin/xbuild"
let g:fsharp_completion_helptext=1
let g:fsharp_only_check_errors_on_write=1
" php.vim
function! PhpSyntaxOverride()
hi! def link phpDocTags phpDefine
hi! def link phpDocParam phpType
endfunction
augroup phpSyntaxOverride
autocmd!
autocmd FileType php call PhpSyntaxOverride()
augroup END