-
Notifications
You must be signed in to change notification settings - Fork 1
/
.vimrc
677 lines (581 loc) · 21.2 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
" vimrc
" Author: Will Gray <graywh@gmail.com>
" Options {{{1
" set all& " Set everything to the default
set nocompatible " Vim is better than Vi
" Path Munging {{{2
if has('win32')
let &runtimepath = substitute(&runtimepath, '\(\~\|'.$USER.'\)/vimfiles\>', '\1/.vim', 'g')
endif
silent! call pathogen#infect('bundles')
" Filetype {{{2
" Enabled file type detection
" Use the default filetype settings. If you also want to load indent files
" to automatically do language-dependent indenting add 'indent' as well.
if has('autocmd') && exists(':filetype') == 2
filetype plugin indent on
endif
if exists(':syntax') == 2
syntax enable
syntax sync fromstart
endif
" Mouse {{{2
if has('mouse')
set mouse=a " Use the mouse for all modes
endif
set mousemodel=popup_setpos " Reposition the cursor on right-click
" Keyboard {{{2
set notimeout " Don't timeout on mappings
set ttimeout " Timeout on keycodes
set ttimeoutlen=100 " Keycodes shouldn't take long
" Terminal {{{2
set title " Let Vim decide
let &titleold=$USER.'@'.$HOST.': '.$PWD"
set icon " Let Vim decide
set ttyscroll=5 " Redraw when scrolling a long ways
let &t_RV="\<Esc>[>c" " Let Vim check for xterm-compatibility
set ttyfast " Because no one should have to suffer
set ttymouse=xterm2 " Assume xterm mouse support
" Navigation {{{2
set nostartofline " Avoid moving the cursor when moving around
set scrolloff=3 " Leave lines next to window edge
set showmatch " Show matching brackets.
set sidescrolloff=10 " Leave some characters next to window edge (w/ nowrap)
if exists('&virtualedit')
if v:version >= 700
set virtualedit=onemore " Allow cursor to be on the newline
endif
endif
" Editing {{{2
set backspace=indent,eol,start " More powerful backspacing
set nrformats=hex,octal,alpha " Recognize hexadecimal, octal, and characters for ctrl-a/x
set textwidth=78 " Seems like a good place to break lines
set wrapmargin=0 " Don't break lines based on window size
" Formatting {{{2
set formatoptions=
set formatoptions+=c " Format comments
set formatoptions+=r " Continue comments by default
set formatoptions+=o " Make comment when using o or O from comment line
set formatoptions+=q " Format comments with gq
set formatoptions+=n " Recognize numbered lists
set formatoptions+=2 " Use indent from 2nd line of a paragraph
set formatoptions+=l " Don't break lines that are already long
set formatoptions+=1 " Break before 1-letter words
set formatoptions+=j " Remove comment leader when joining lines
if exists('&formatlistpat')
set formatlistpat=^\\s*\\(\\d\\+\\\|\\*\\\|-\\\|∙\\\|•\\\|∘\\\|·\\)[]:.)}\\t\ ]\\s*
endif
" Tabs, Indents {{{2
set autoindent " Always set autoindenting on
set expandtab " Always expand tabs to spaces
set shiftwidth=4 " Use 4 spaces for each level of indention
set smarttab " Use 'sw' at begining of line, 'ts' otherwise
set softtabstop=8 " To make backspacing over expanded tabs easier
set tabstop=8 " What tabs are meant to be
" Completion {{{2
if exists('&completeopt')
set completeopt=longest " Start with longest part
set completeopt+=menu,preview " then show a menu
endif
" Command-line {{{2
set wildmenu " Use a menu to show tab-completions
set wildmode=longest:full,full " Complete longest, tab through matches
" Suffixes that get lower priority when doing tab completion for filenames.
" These are files we are not likely to want to edit or read.
set suffixes=.bak,~,.swp,.swo,.o,.d,.info,.aux,.log,.dvi,.pdf,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc,.pyc,.pyd,.dll
set cedit=<C-o>
" Encoding {{{2
if has('multi_byte') && &encoding !~? '^u\(tf\|cs\)'
if !strlen(&termencoding) && exists(':let') == 2
let &termencoding = &encoding
endif
set encoding=utf-8
endif
" Searching, Patterns {{{2
set ignorecase " Ignore case when searching
set incsearch " Incremental search
set smartcase " Search case-insensitive mostly
set wrapscan " Searches wrap around end of file
" Windows, Buffers {{{2
set hidden " Allow hiding changed buffers
if exists('&switchbuf')
set switchbuf=useopen
if v:version >= 700
set switchbuf+=usetab
endif
endif
set splitbelow " New window goes below
set splitright " New windows goes right
" Display {{{2
if (has('gui_running') || &t_Co > 16) && exists('&cursorline')
set cursorline " Highlight the current line
endif
set display=lastline " Show as much as possible of wrapped lines
if exists('&foldcolumn')
set foldcolumn=1 " Show top-level fold sections
endif
if has('folding')
set nofoldenable " Disable folds by default
set foldmethod=syntax " Fold by syntax
" set foldminlines=0 " Allow folding single lines
endif
set linebreak " Don't wrap words
set list " Add visual clues (disables 'linebreak')
set number " Show line numbers
if exists('&numberwidth')
set numberwidth=4
endif
set wrap " Wrap long lines
set listchars=
if has('multi_byte') && (&termencoding =~? '^u\(tf\|cs\)' || (! strlen(&termencoding) && &encoding =~? '^u\(tf\|cs\)')) && (v:version >= 602 || v:version == 601 && has('patch469'))
" set listchars+=eol:↵
set listchars+=tab:»·
if v:version >= 700
set listchars+=nbsp:+
endif
set listchars+=trail:·
set listchars+=extends:→
set listchars+=precedes:←
else
if v:version < 603
" :print may behave badly with this disabled
" set listchars+=eol:$
endif
set listchars+=tab:>-
if v:version >= 700
set listchars+=nbsp:+
endif
set listchars+=trail:.
set listchars+=extends:>
set listchars+=precedes:<
endif
" Messages, Info, Status {{{2
set laststatus=2 " Always display the statusline
set ruler " Show position even without status line
set showcmd " Show (partial) command in status line
set vb t_vb= " Disable visual and audible bell
" Viminfo {{{2
set history=50 " Keep 50 lines of command line history
set viminfo=
set viminfo+='100 " Remember 100 previously edited files' marks
set viminfo+=! " Remember some global variables
set viminfo+=h " Don't restore the hlsearch highlighting
" Reading, Writing {{{2
set modeline " Let files set their own options
set modelines&
set fileformats=unix,mac,dos " End-of-line character
if exists('&undofile')
set undofile " Keep undo files
set undolevels=1000 " Keep plenty of undos
endif
" Diff mode {{{2
if exists('&diffopt')
set diffopt=filler
set diffopt+=iwhite
if v:version >= 700
set diffopt+=vertical
set diffopt+=foldcolumn:2
endif
endif
" Other {{{2
set winaltkeys=no " Don't use ALT to access the menu
" Colors {{{2
if exists(':colorscheme') == 2
colorscheme graywh
endif
" Plugins {{{1
if exists(':runtime') == 2 && &loadplugins
runtime! macros/matchit.vim
sunmap %
sunmap g%
sunmap [%
sunmap ]%
sunmap a%
endif
" Options {{{2
if exists(':let') == 2
let g:colorchart_origin = { 88: 0, 256: 7 }
let g:colorchart_angle = { 88: 0, 256: 4 }
let g:colorchart_chart = { 88: "ribbon" }
if &t_Co < 256 && !has('gui_running')
let g:color_indent_size = 1
hi! link colorIndentOdd colorIndentEven
endif
let g:fit_manpages_to_window = 1 " Let man format manpages to fit the window
let g:liquid_highlight_types = ["html","erb=eruby","html+erb=eruby.html", "ruby"]
let g:php_sql_query = 1
let g:php_htmlInStrings = 1
let g:php_baselib = 1
let g:python_highlight_builtins = 1
let g:python_highlight_exceptions = 1
let g:python_highlight_string_formatting = 1
let g:python_highlight_doctests = 1
let g:rails_gnu_screen = 0
" let ruby_fold = 1
let ruby_no_expensive = 1
let g:space_disable_select_mode = 1
let g:space_no_character_movements = 1
let g:space_no_search = 1
let g:space_no_jump = 1
let g:sql_type_default = 'mysql'
let g:surround_indent = 1
let g:tex_flavor = 'pdflatex' " Use pdflatex as the tex compiler
let g:Twiki_SourceHTMLSyntax = 1 " Let TWiki include HTML syntax
let g:twiki_highlight_r = 1 " <highlight> tags include R
let g:twiki_highlight_perl = 0 " <highlight> tags include perl
let g:VCSCommandDeleteOnHide = 1
endif
" Functions {{{1
if exists(':function') == 2
function! SimpleFoldText() " {{{2
let text = getline(v:foldstart)
if text[-1:] != ' '
let text .= ' '
endif
return text
endfunction
function! MyFoldText() " {{{2
let suba = getline(v:foldstart)
let suba = substitute(suba, '{{{\d\=\|}}}\d\=', '', 'g')
let suba = substitute(suba, '\s*$', '', '')
" let subb = getline(v:foldend)
" let subb = substitute(subb, '{{{\d\=\|}}}\d\=', '', 'g')
" let subb = substitute(subb, '^\s*', '', '')
" let subb = substitute(subb, '\s*$', '', '')
let lines = v:foldend - v:foldstart + 1
let text = suba
" if lines > 1 && strlen(subb) > 0
" let text .= ' ... '.subb
" endif
let fillchar = matchstr(&fillchars, 'fold:\zs.')
if strlen(fillchar) == 0
let fillchar = '-'
endif
let lines = repeat(fillchar, 4).' ' . lines . ' lines '.repeat(fillchar, 3)
if has('float')
let nuw = max([float2nr(log10(line('$')))+3, &numberwidth])
else
let nuw = &numberwidth
endif
let n = winwidth(winnr()) - &foldcolumn - nuw - strlen(lines)
let text = text[:min([strlen(text), n])]
if text[-1:] != ' '
if strlen(text) < n
let text .= ' '
else
let text = substitute(text, '\s*.$', '', '')
endif
endif
let text .= repeat(fillchar, n - strlen(text))
let text .= lines
return text
endfunction
function! MyFoldIndent() " {{{2
let line = getline(v:lnum)
if line =~# '^$'
return 0
endif
let numl = LeadingSpace(line)
if line =~# &formatlistpat && &formatoptions =~# 'n'
return '>' . ((numl / &shiftwidth) + 1)
endif
if (numl % &shiftwidth) > 0 || numl == 0
return '='
endif
return numl / &shiftwidth
endfunction
function! LeadingSpace(line) " {{{2
let line = substitute(a:line, '^\(\s*\)\S.*$', '\1', '')
let line = substitute(line, '\t', repeat(' ', &tabstop), 'g')
return strlen(line)
endfunction
function! StatusLineTrailingSpaceWarning() " {{{2
" return '[\s$]' if trailing whitespace is detected
" return '' otherwise
if !exists('b:statusline_trailing_space_warning')
if !&readonly && &modifiable && search('\s\+$', 'nw') != 0
let b:statusline_trailing_space_warning = '[\s$]'
else
let b:statusline_trailing_space_warning = ''
endif
endif
return b:statusline_trailing_space_warning
endfunction
function! StatusLineTabWarning() " {{{2
" return '[&et]' if &expandtab is set wrong
" return '[mixed-indenting]' if spaces and tabs are used to indent
" return an empty string if everything is fine
if !exists('b:statusline_tab_warning')
if &filetype == 'help' || &readonly == 1 || &modifiable == 0
let b:statusline_tab_warning = ''
else
let tabs = search('^\t', 'nw') != 0
let spaces = search('^ ', 'nw') != 0
if tabs && spaces
let b:statusline_tab_warning = '[mixed-indenting]'
elseif (spaces && !&expandtab) || (tabs && &expandtab)
let b:statusline_tab_warning = '[&et]'
else
let b:statusline_tab_warning = ''
endif
endif
endif
return b:statusline_tab_warning
endfunction
function! StatusLineEncodingBombWarning() " {{{2
if &fileencoding !~ '^$\|utf-8' || &bomb
return '[' . &fileencoding . (&bomb ? '-bom' : '') . ']'
else
return ''
endif
endfunction
if exists('*synstack') " {{{2
function! ShowSynStack()
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
endfunction
endif
function! ShowSynIDs() " {{{2
let id = synID(line('.'),col('.'),1)
let hi = synIDattr(id,'name')
let trans = synIDattr(synID(line('.'),col('.'),0),'name')
let lo = synIDattr(synIDtrans(id),'name')
echo 'hi<' . hi . '> trans<' . trans . '> lo<' . lo . '>'
endfunction
function! VisualNavigation() " {{{2
let mds = ['n', 'o', 'x']
let keys = ['0', '^', '$', '<Home>', '<End>', 'k', 'j', '<Up>', '<Down>']
if !exists('b:my_visual_navigation_maps')
let b:my_visual_navigation_maps = 1
echomsg 'Enabled visual navigation'
setlocal wrap
for key in keys
for md in mds
if mapcheck(key, md) == ''
exec 'silent '.md.'noremap <buffer> <unique> '.key.' g'.key
endif
endfor
endfor
else
unlet b:my_visual_navigation_maps
echomsg 'Disabled visual navigation'
setlocal wrap<
for key in keys
for md in mds
if mapcheck(key, md) == 'g'.key
exec 'silent '.md.'unmap <buffer> '.key
endif
endfor
endfor
endif
endfunction
function! LastModified() "{{{2
" autocmd BufWritePre * call LastModified()
if &modified
let save_cursor = getpos(".")
silent! keepjumps 1,4substitute/ Last Modified: \zs.*/\=strftime('%c')/
call setpos('.', save_cursor)
endif
endfunction
function! InvertColors() "{{{2
let swapbw = { 'Black' : 'White', 'White' : 'Black' }
%substitute/\<cterm[fb]g=\zs\(Black\|White\)/\=get(swapbw, submatch(1), '')/g
let swap = { 'Red' : 'Cyan', 'Green' : 'Magenta', 'Yellow' : 'Blue', 'Blue' : 'Yellow', 'Magenta' : 'Green', 'Cyan' : 'Red', 'Gray' : 'Gray', 'Grey' : 'Grey', 'Light' : 'Dark', 'Dark' : 'Light' }
%substitute/\<cterm[fb]g=\zs\(Dark\|Light\)\=\(Red\|Green\|Yellow\|Blue\|Magenta\|Cyan\|Gr[ae]y\)/\=get(swap, submatch(1), 'Dark') . get(swap, submatch(2), '')/g
%substitute/\<gui\(fg\|bg\|sp\)=#\zs\(\x\{6}\)/\=printf('%06X', 16777215 - str2nr(submatch(2), 16))/g
endfunction
endif
" Commands {{{1
if exists(':command') == 2
" Compare a modified file to what is saved on disk
command! DiffOrig
\ vertical new | set bt=nofile bh=wipe |
\ read # | 0 delete _ | diffthis | wincmd p | diffthis
command! DiffOff
\ only | diffoff | set fdc<
" Replace tabs with 'shiftwidth' spaces
if has('ex_extra')
command! -bang -range=% ReTab
\ silent! unlet b:statusline_tab_warning |
\ let ts=&l:tabstop | let &l:tabstop=&shiftwidth |
\ <line1>,<line2>retab<bang> |
\ let &l:tabstop=ts | unlet ts
endif
" Remove trailing space
command! -range=% UnTrail
\ silent! unlet b:statusline_trailing_space_warning |
\ let temp = @@ |
\ keepjumps <line1>,<line2>substitute/\s\+$//e |
\ let @@ = temp
" Shift the position under the cursor to column N
if has('ex_extra')
command! -nargs=1 Shift
\ execute 'normal '.(<args>-col('.')).'i '
endif
" Save using sudo
if executable('sudo') && executable('tee')
command! -bar SUwrite
\ setlocal nomodified |
\ execute 'write !sudo tee % >/dev/null' |
\ let &l:modified = v:shell_error
endif
" D'oh
command! -bang -nargs=? -complete=help H
\ help<bang> <args>
endif
" Status line {{{1
set statusline=
set statusline+=%4(%n%)\ " Buffer number (4 columns, lines up with the line numbers most of the time)
set statusline+=%<%f\ " Relative filename & path (truncatable)
set statusline+=%y%m%r%w " Flags: filetype, modified/nomodifiable, read-only, preview
set statusline+=%1* " Various warnings
set statusline+=%{StatusLineTabWarning()} " Indentation
set statusline+=%{StatusLineTrailingSpaceWarning()} " Trailing space
set statusline+=%{&ff=='unix'?'':'['.&ff.']'} " &fileformat != 'unix'
set statusline+=%{StatusLineEncodingBombWarning()} " &fileencoding, &bomb
set statusline+=%{&eol?'':'[noeol]'} " &noeol
set statusline+=%* " End of warnings section
set statusline+=%=\ " Separate left from right
" set statusline+=%{synIDattr(synID(line('.'),col('.'),1),'name')}\ " Current highlight group
set statusline+=%b,0x%-8B\ " Current character in decimal and hex representation
set statusline+=%-12(%l,%c%V%)\ %P " Current line and column, file percentage (set 'ruler')
" Autocommands {{{1
if has('autocmd')
augroup vimrcEx
" clear all existing autocmds
autocmd!
" recalculate the trailing whitespace warning when idle, and after writing
autocmd CursorHold,BufWritePost * unlet! b:statusline_trailing_space_warning
" recalculate the tab warning when idle and after writing
autocmd CursorHold,BufWritePost * unlet! b:statusline_tab_warning
if exists(':sort') == 2
autocmd BufWritePre ~/.irssi/saved_colors sort i | sort /:/ n
endif
if has('float')
autocmd BufRead * let &l:numberwidth = max([float2nr(log10(line('$')))+3, &numberwidth])
endif
augroup END
endif
" Keymaps {{{1
" Disable F1 for help {{{2
nmap <F1> <Nop>
nmap <A-F1> <Nop>
nmap <C-F1> <Nop>
imap <F1> <Nop>
imap <S-F1> <Nop>
imap <A-F1> <Nop>
imap <C-F1> <Nop>
" make Q like before {{{2
nnoremap Q gq
nnoremap QQ gqgq
xnoremap Q gq
" swap ' and ` {{{2
noremap ' `
sunmap '
noremap ` '
sunmap `
noremap g' g`
sunmap g'
noremap g` g'
sunmap g`
" make Y like D & C {{{2
nnoremap Y y$
xnoremap Y y$
" Search highlight {{{2
if has('extra_search')
nnoremap <silent> <F6> :set hlsearch!<CR>:set hlsearch?<CR>
nnoremap <silent> <C-l> :nohlsearch<CR><C-l>
endif
" Autocomplete {{{2
" if exists('*pumvisible')
" inoremap <expr> <C-space> pumvisible() \|\| &omnifunc == '' ? "\<C-n>" : "\<C-x>\<C-o>"
" endif
" Add new line indented here {{{2
if has('ex_extra')
nnoremap <silent> <Leader>o :let ospaces=virtcol('.')-1<CR>o<Esc>:execute 'normal '.ospaces.'i '<CR>:.retab!<CR>A
nnoremap <silent> <Leader>O :let ospaces=virtcol('.')-1<CR>O<Esc>:execute 'normal '.ospaces.'i '<CR>:.retab!<CR>A
endif
" Show the syntax highlighting groups for the item under the cursor {{{2
if exists('*ShowSynStack')
nnoremap <silent> <F7> :call ShowSynStack()<CR>
endif
if exists('*ShowSynIDs')
nnoremap <silent> <F8> :call ShowSynIDs()<CR>
endif
" User commands
if exists(':UnTrail') == 2
nnoremap <silent> <leader>ut :UnTrail<CR>
xnoremap <silent> <leader>ut :UnTrail<CR>
endif
if exists(':ReTab') == 2
nnoremap <silent> <leader>rt :ReTab<CR>
xnoremap <silent> <leader>rt :ReTab<CR>
endif
" Command-line navigation {{{2
cnoremap <C-a> <Home>
cnoremap <C-x> <C-a>
cnoremap <C-b> <Left>
cnoremap <C-h> <Left>
cnoremap <C-f> <Right>
" Command-line completion {{{2
cnoremap <expr> <C-p> wildmenumode() ? "\<C-p>" : "\<Up>"
cnoremap <expr> <C-n> wildmenumode() ? "\<C-n>" : "\<Down>"
cnoremap <Up> <C-p>
cnoremap <Down> <C-n>
" Arrow keys for window movement {{{2
nnoremap <silent> <Left> <C-w>h
nnoremap <silent> <Right> <C-w>l
nnoremap <silent> <Up> <C-w>k
nnoremap <silent> <Down> <C-w>j
" Ctrl-Left/Right for buffer cycling {{{2
nnoremap <silent> <C-Left> :bp<CR>
nnoremap <silent> <C-Right> :bn<CR>
nnoremap <silent> <C-Up> :bp<CR>
nnoremap <silent> <C-Down> :bn<CR>
" Wrap-based movements {{{2
nnoremap <silent> <F5> :call VisualNavigation()<CR>
" Screen {{{2
map <C-_> <Nop>
map! <C-_> <Nop>
" Folding {{{2
if has('eval')
for k in ['i', 'm', 'M', 'n', 'N', 'r', 'R', 'v', 'x', 'X']
execute "nnoremap <silent> Z".k." :windo normal z".k."<CR>"
endfor
endif
" Select last changed text {{{2
nnoremap <leader>v `[v`]
nnoremap <leader>V `[V`]
nnoremap <leader><C-v> `[<C-v>`]
" Terminal Stuff {{{1
" map <C-@> <C-space>
" map! <C-@> <C-space>
" XXX Fix vim bug when exiting alt screen {{{2
if exists('&t_te') && exists('&t_op')
let &t_te=&t_te.&t_op
endif
" Manually set the titlestring escape sequences for any terminal {{{2
" that hasn't already and is not known to not support them
if &term !~? '^\v(linux|cons|vt)' && ! strlen(&t_ts) && ! strlen(&t_fs)
let &t_ts="\<Esc>]2;"
let &t_fs="\x7"
let &t_IS="\<Esc>]1;"
let &t_IE="\x7"
endif
" change the xterm cursor for insert mode {{{2
if &term =~? '^xterm' && exists('&t_SI') && &t_Co > 1
" let &t_SI=''
" let &t_EI=''
" color
" let &t_SI.="\<Esc>]12;purple\x7"
" let &t_EI.="\<Esc>]112\x7"
" shape
" let &t_SI.="\<Esc>[4 q"
" let &t_EI.="\<Esc>[2 q"
endif
" Collected Tips {{{1
" :%substitute/\(\d\d\)\(:\d\d\)\{1,2} \(AM\|PM\)/\=(submatch(3) == 'PM' && submatch(1) < 12 ? submatch(1)+12 : submatch(3) == 'AM' && submatch(1) == 12 ? '00' : submatch(1)).submatch(2)/
" Change to different capitalization {{{2
" under_score_case to camelCase
" nnoremap <Leader>sc ciw<C-r>=substitute(@", '_\(\w\)', '\u\1', 'g')<CR><Esc>
" camelCase to under_score_case
" nnoremap <Leader>cs ciw<C-r>=substitute(@", '\l\zs\(\u\)', '_\l\1', 'g')<CR><Esc>