-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
661 lines (556 loc) · 18 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
" Cheat Sheet
"
" Ack.vim
" :Ack [options] {pattern} [{directories}]
" :Ack, :AckAdd, :LAck, :LAckAdd
" o to open (same as enter)
" O to open and close quickfix window
" go to preview file (open but maintain focus on ack.vim results)
" t to open in new tab
" T to open in new tab silently
" h to open in horizontal split
" H to open in horizontal split silently
" v to open in vertical split
" gv to open in vertical split silently
" q to close the quickfix window
"
" Vim-dispatch
" :Make - background make, auto open quickfix window
" :Make! - background make, open quickfix window with :Copen
" :Dispatch - background task, captures output
" :Start - foreground task, doesn't capture output
" :Start! - background task, doens't capture output
"
" EasyAlign
" 1) <enter> in visual mode or <leader>a followed by movement to start
" interactive mode
" 2) Optional: N-th delimiter (default: 1)
" - 1 Around the 1st occurrences of delimiters
" - 2 Around the 2nd occurrences of delimiters
" - ...
" - * Around all occurrences of delimiters
" - ** Left-right alternating alignment around all delimiters
" - - Around the last occurrences of delimiters (-1)
" - -2 Around the second to last occurrence of delimiters
" 3) Delimiter key (a single keystroke: <space>, =, ;, ., |, &, , or <c-x>)
" - Regex delimiter: use <c-x> to type a regular expression
" 4) Optional: Enter keys to select alignment mode (left, right, or center)
" 5) Optional: Addition alignment options
" - <c-f> | Filter | Input string ([gv]/.*/?)
" - <c-l> | left_margin | Input number or string
" - <c-r> | right_margin | Input number or string
" - <left> | stick_to_left | true or false
" - <right> | stick_to_right | true or false
" - <down> | *_margin | margin = 0
" 6) Delimiter key (a single keystroke: <space>, =, ;, ., |, &, , or <c-x>)
silent! so ~/.vim/bundles.vim
silent! so ~/.vim/functions.vim
set wildignore=*.db,*.doc,*.docx,*.~,*.exe,*.dll,*.dat*,*.png,*.jpg,*.jpeg,*.gif,*.DAT,*.DAT*,*.psd,*.lnk,*.mp4,*.pyc,Backup\**
" Sets shell based on environment
if has("win32")
set shell=cmd.exe
else
set shell=/bin/zsh
endif
set number
set relativenumber
syntax on
" Sets colorscheme. Always use molokai unless you're in a terminal on Windows
" (no 256 colors on Windows term)
set t_Co=256
if has("win32") && !has("gui_running")
colorscheme desert
else
colorscheme molokai
endif
if !has("win32")
set t_Co=16
silent! colorscheme desert
silent! colorscheme ir_black
endif
"""""""""""
" OPTIONS "
"""""""""""
let mapleader = "\<space>"
set backupdir=~/.vim/backups
set noswapfile " no swap files
set autowrite " autowrites on :next, etc.
set ruler " show rows,columns in status line
set backspace=2 " make backspace actually work
set scrolloff=7 " keep the cursor 7 lines below/above the top/bottom of the window
set wildmenu " visual responses to <tab> in the command line
set cursorline " highlight the line the cursor is on
set ts=4 sts=4 sw=4 et " sane tab settings
set laststatus=2 " always have a status line
set sc " show commands in the status line as you type them
set cindent
set autoindent
set encoding=utf-8
set backupcopy=yes
set ignorecase
set smartcase
set incsearch
set splitbelow
set splitright
set timeout timeoutlen=3000 ttimeoutlen=100
set hlsearch
set history=1000
set linebreak
set textwidth=0
set nostartofline " keep cursor in same column when using motions
runtime! macros/matchit.vim
highlight ColorColumn guibg=#293739
set colorcolumn=81
set synmaxcol=800
" For use with `man`
let $PAGER=''
" Persistent Undo
set undofile
set undodir=~/.vim/undo
set undolevels=10000 " numbers of particular undos to save
set undoreload=100000 " number of undo lines to save
if !isdirectory(expand(&undodir))
call mkdir(expand(&undodir))
endif
"""""""""""
" BUFFERS "
"""""""""""
" quit buffer
nnoremap Q :bd<cr>
" REALLY quit
nnoremap RQ :bd!<cr>
" next/prev buffer
nnoremap <Tab> :bn<CR>
nnoremap <BS> :bp<CR>
" Copy buffer to system clipboard
nnoremap <c-c> :%y +<cr>
" update buffer
nnoremap S :up<cr>
" Open Scratch buffer
nnoremap <leader>tmp :Scratch<CR>
" write and source current buffer
nnoremap <leader>ss :w <bar> so %<cr>
" Open buffer directory in explorer
nnoremap <leader>oe :silent !explorer.exe %:p:h<cr>
" Open buffer in chrome
nnoremap gB :silent !chrome "%:p"<CR>
" bufdo - does last command in all other buffers
function! BufDoLastCommand()
undo
silent! bufdo @:
endfunction
command! -nargs=0 Bufdo :call BufDoLastCommand()
" type BD to do a comment in all buffers
cabbrev BD silent! bufdo
" Edit/save/source vimrc
if has("win32")
nnoremap <Leader>ev :vsplit ~/Documents/GitHub/dotfiles/.vimrc<CR><C-w>L
else
nnoremap <Leader>ev :vsplit ~/dotfiles/.vimrc<CR><C-w>L
endif
nnoremap <Leader>sv :w <bar> so %<CR>:bdel<CR>
" BundleClean/Install
nnoremap <leader>bc :w <bar> so % <bar> BundleClean<CR>
nnoremap <leader>bi :w <bar> so % <bar> BundleInstall<CR>
"""""""""""
" WINDOWS "
"""""""""""
" Window movement
nnoremap <up> <c-w>k
nnoremap <down> <c-w>j
nnoremap <right> <c-w>l
nnoremap <left> <c-w>h
" resize current window by +/- 5
" FIXME These all broken in terminal. A darn shame.
nnoremap <S-left> :vertical resize -5<cr>
nnoremap <S-down> :resize +5<cr>
nnoremap <S-up> :resize -5<cr>
nnoremap <S-right> :vertical resize +5<cr>
nnoremap <C-S-right> :vertical resize<CR>
nnoremap <C-S-left> <c-w>l:vertical resize 40<CR><c-w>h
nnoremap <C-S-up> :resize 30<CR>
nnoremap <C-S-down> :resize<CR>
""""""""""""
" MOVEMENT "
""""""""""""
" Move around lines better sometimes
nnoremap <C-h> ^
nnoremap <C-k> -
nnoremap <C-j> <C-m>
"""""""""""
" EDITING "
"""""""""""
" Pastes system clipboard. Use <c-q> to enter visual block mode. You may have
" to change terminal settings for it to work.
nnoremap <c-v> "+P
" Prevents character deletes from going into a register (_ is a blackhole)
nnoremap x "_x
" Add a semicolon EOL.
nnoremap a; m`A;<esc>``
" Bubble single lines
nnoremap <C-Up> ddkP
nnoremap <C-Down> ddp
" Bubble multiple lines
vnoremap <C-Up> xkP`[V`]
vnoremap <C-Down> xp`[V`]
" split line
nnoremap K i<cr><esc>
" Spell check
nnoremap <leader>sc ea<c-x><c-s><esc>
" Isolate line
nnoremap <leader><space><space> ddO<cr><esc>P
" Isolate Visual selection
vnoremap <leader><space><space> dO<cr><esc>P
" zip a thing over to the end of line
nnoremap zl :let @z=@"<cr>x$p:let @"=@z<cr>
""""""""""""""
" FORMATTING "
""""""""""""""
" EasyAlign
nmap <leader>a <Plug>(LiveEasyAlign)
vmap <cr> <Plug>(LiveEasyAlign)
" Start Tabular.vim
" FIXME. Just detects a space in terminal
noremap <S-Space> :Tab/
" Calls Tidy
nnoremap <leader>x :silent %! tidy --vertical-space no --doctype omit --output-html yes --wrap 0 --show-errors 0 --show-body-only auto --indent auto --indent-spaces 4 -q -i<cr><cr>:silent! %s/<\/li>\zs\n\ze\s*\n\s*<li>//g<cr>
" Run Last :Tabularize
nnoremap <leader>lt :Tab<up><CR>
" Beautifiers
nnoremap <leader>jx :call JsBeautify()<cr>
nnoremap <leader>hx :call HtmlBeautify()<cr>
nnoremap <leader>cx :call CSSBeautify()<cr>
vnoremap <leader>jx :call JsBeautify("'<","'>")<cr>
vnoremap <leader>hx :call HtmlBeautify("'<","'>")<cr>
vnoremap <leader>cx :call CSSBeautify("'<","'>")<cr>
"""""""""""""
" SEARCHING "
"""""""""""""
" Quick search and replace
nnoremap ? :%s/<c-r>///g<left><left>
vnoremap ? :s/<c-r>///g<left><left>
" Start a vimgrep and open results window
" FIXME in terminal
nnoremap <C-space> :vim //g ** \| cw<home><right><right><right><right><right>
nnoremap <C-S-space> :cex [] \| bufdo silent! noau vimgrepadd //g % \| cw<left><left><left><left><left><left><left><left><left>
" centers search
nnoremap n nzz
nnoremap N Nzz
" clear search highlights
nnoremap <c-l> :nohl<cr><c-l>
""""""""""""""""""""
" COMPILING/MAKING "
""""""""""""""""""""
" make and run
nnoremap <leader>ma :update<cr>:Make %:r<cr>
" for D
nnoremap <leader>md :up \| silent! !dmd %<cr>:copen<cr><c-w>w:!%:r
"""""""""""
" UTILITY "
"""""""""""
" Togggle set wrap
nnoremap <Leader>w :set wrap!<CR>
" Changes windows to the directory of the current buffer
nnoremap cd :lcd %:p:h<CR>:cd<CR>
" Diff THIS
nnoremap <leader>dt :difft<CR>
nnoremap <leader>ds :vert diffsplit<CR>
nnoremap <leader>do :diffo!<CR>
" Sum first numbers
nnoremap <leader>sf :silent! %s/\d\+/\=Sum(submatch(0))/g<cr>:echo g:S<cr>
" Sum regex numbers
nnoremap <leader>sr :silent! %s//\=Sum(submatch(0))/g\|echo g:S<home><right><right><right>
" Replace stupid quotes and TM and R signs
nnoremap <leader>qr :%s/[“”]/"/ge\|%s/[‘’]/'/ge\|%s/®/\®/ge\|%s/™/\™/ge\|%s/\s\+&\s\+/ \& /ge<cr>
" Do Maths
nnoremap <leader>dm :DoMaths<cr>
nnoremap <leader>d= :DoMathsVerbose<cr>
" Run ctags
nnoremap <leader>ct :silent !ctags -R<cr>
" Copy visual selection to system clipboard. Use v, V, or <c-q> to exit visual
" mode without copying.
vnoremap <c-c> "+y
" Fix syntax
nnoremap U :syntax sync fromstart<cr>:redraw!<cr>
""""""""
" MISC "
""""""""
" Fix Y
nnoremap Y y$
" move backward a jump
nnoremap _ <c-o>
" move forward a jump
nnoremap + <c-i>
"""""""""""""""
" PLUGIN MAPS "
"""""""""""""""
" open snippets
nnoremap <leader>ne :vsp \| NeoSnippetEdit<cr>
" Fugitive commands
nnoremap <leader>gd :Gdiff<CR>
nnoremap <leader>gs :Gstatus<CR>
nnoremap <leader>gc :Gcommit<CR>
nnoremap <leader>gp :Git push<CR>
nnoremap <leader>gb :Gbrowse<CR>
" Surround.vim maps
" wrap <ul> tag around visual selection
nnoremap <leader>rul :normal ysii<ul>vit><lt><lt><cr>
" wrap <li> tag on each line in visual selection
vnoremap <leader>rli :normal yss<li><cr>
""""""""""""""""""""
" INSERT MODE MAPS "
""""""""""""""""""""
" More undo points
inoremap . .<C-g>u
inoremap ! !<C-g>u
inoremap ? ?<C-g>u
inoremap : :<C-g>u
inoremap ; ;<C-g>u
" Add semi-colon to EOL
inoremap <c-l> <C-o>m`<C-o>A;<C-o>``
inoremap jj <esc>m`A;<esc>``
" Goto EOL
inoremap <c-a> <c-o>A
" The only way to exit insert mode
inoremap jk <esc>
" Omni completion
inoremap <C-space> <c-x><c-o>
" paste from system clipboard
inoremap <c-c> <c-r>+
" extra del key
inoremap <c-f> <c-o>x
" next line
inoremap <c-j> <esc>o
" HTML tag completion
inoremap <silent> <C-X><space> <esc>ciW<lt><c-r>"></<c-r>"><esc>F<i
inoremap <silent> <C-X><cr> <esc>ciW<lt><c-r>"><cr></<c-r>"><esc>O<tab>
" Do maths
inoremap <c-e> <esc>:DoMathsVerbose<cr>A
"""""""""""""""""""""
" Command Mode maps "
"""""""""""""""""""""
" Heresy.
cnoremap <C-a> <home>
cnoremap <C-e> <end>
cnoremap <c-p> <up>
cnoremap <c-n> <down>
cnoremap <c-f> <right>
cnoremap <c-b> <left>
cnoremap <m-f> <c-right>
cnoremap <m-b> <c-left>
" force write a ro file
cnoremap w!! %!sudo tee > /dev/null %
" Command abbrevs
cabbrev Set set
cabbrev W w
cabbrev Q q
cabbrev Qa qa
cabbrev Wq wq
cabbrev Wqa wqa
cabbrev Read read
cabbrev R r
cabbrev q1 q!
cabbrev %S %s
cabbrev Cd cd
cabbrev E e
""""""""""""
" Commands "
""""""""""""
" does maths
command! DoMaths
\ exec '.g/\./s/^/scale=2; /' | exec '.!bc' | norm <c-l>
" Shows answer for maths
command! DoMathsVerbose
\ .y |
\ exec '.g/\./s/^/scale=2; /' |
\ exec '.!bc' |
\ exec 'norm <c-l>I<c-r>0 = <esc>kJ$vB"+y0'
"""""""""""""""""""""""""""
" PLUGIN MAPS AND OPTIONS "
"""""""""""""""""""""""""""
" vim-sneak
" replace 'f' with inclusive 1-char Sneak
let g:sneak#streak = 1
nmap f <Plug>Sneak_f
nmap F <Plug>Sneak_F
xmap f <Plug>Sneak_f
xmap F <Plug>Sneak_F
omap f <Plug>Sneak_f
omap F <Plug>Sneak_F
" replace 't' with exclusive 1-char Sneak
nmap t <Plug>Sneak_t
nmap T <Plug>Sneak_T
xmap t <Plug>Sneak_t
xmap T <Plug>Sneak_T
omap t <Plug>Sneak_t
omap T <Plug>Sneak_T
" Colorizer
let g:colorizer_auto_filetype='css,html,javascript'
" auto-pairs
let g:AutoPairs = {'(':')', '[':']', '{':'}', "'":"'", '"':'"', '`':'`', '|':'|'}
" Neocomplete
let g:neocomplete#enable_at_startup = 1
" use smartcase
let g:neocomplete#enable_smart_case = 1
" set minumum syntax keyword length
let g:neocomplete#sources#syntax#min_keyword_length = 3
let g:neocomplete#lock_buffer_name_pattern = '\*ku\*'
" autocomplpop like behavior
let g:neocomplete#enable_auto_select = 0
let g:neocomplete#enable_auto_delimiter = 1
let g:neocomplete#enable_prefetch = 1
" Define dictionary
let g:neocomplete#sources#dictionary#dictionaries = {
\ 'default' : '',
\ }
" Define keyowrd
if !exists('g:neocomplete#keyword_patterns')
let g:neocomplete#keyword_patterns = {}
endif
let g:neocomplete#keyword_patterns['default'] = '\h\w*'
" Plugin keymappings
inoremap <silent> <cr> <c-r>=<SID>my_cr_function()<cr>
function! s:my_cr_function()
return neocomplete#smart_close_popup() . "\<cr>"
endfunction
inoremap <expr><c-h> neocomplete#smart_close_popup() . "\<c-h>"
inoremap <expr><bs> neocomplete#smart_close_popup() . "\<c-h>"
inoremap <expr><space> neocomplete#smart_close_popup()
" NeoSnippets
" let neosnippet#snippets_directory = '~/.vim/bundle/neosnippet.vim/autoload/neosnippet/snippets'
" SuperTab like snippets behavior.
" imap <expr><tab> neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)"
" \ : pumvisible() ? "\<c-n>" : "\<tab>"
" smap <expr><tab> neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)"
" \ : pumvisible() ? "\<c-n>" : "\<tab>"
" inoremap <s-tab> <c-p>
" if has('conceal')
" set conceallevel=2 concealcursor=i
" endif
let g:ulti_expand_or_jump_res = 0
function! Ulti_ExpandOrJump_and_getRes()
call UltiSnips#ExpandSnippetOrJump()
return g:ulti_expand_or_jump_res
endfunction
imap <tab> <c-r>=(Ulti_ExpandOrJump_and_getRes() > 0) ? "" : SuperTab('n')<cr>
" Airline
let g:airline_powerline_fonts = 1
" Bufferline
let g:bufferline_echo = 0
" TextObjColumn remaps. The default's conflict with comment objects
let g:skip_default_textobj_word_column_mappings = 1
xnoremap <silent> av :<C-U>call TextObjWordBasedColumn("aw")<CR>
onoremap <silent> av :call TextObjWordBasedColumn("aw")<CR>
xnoremap <silent> iv :<C-U>call TextObjWordBasedColumn("iw")<CR>
onoremap <silent> iv :call TextObjWordBasedColumn("iw")<CR>
xnoremap <silent> aV :<C-U>call TextObjWordBasedColumn("aW")<CR>
onoremap <silent> aV :call TextObjWordBasedColumn("aW")<CR>
xnoremap <silent> iV :<C-U>call TextObjWordBasedColumn("iW")<CR>
onoremap <silent> iV :call TextObjWordBasedColumn("iW")<CR>
" CamelCase
map <silent> w <Plug>CamelCaseMotion_w
map <silent> b <Plug>CamelCaseMotion_b
map <silent> e <Plug>CamelCaseMotion_e
sunmap w
sunmap b
sunmap e
" NERDCommenter options
let g:NERDUsePlaceHolders = 0
let g:NERDSpaceDelims = 1
" Ctrlp Options
let g:ctrlp_mruf_excluse = '*.csv'
let g:ctrlp_open_new_file = 'r'
let g:ctrlp_open_multiple_files = '1r'
let g:ctrlp_clear_cache_on_exit = 0
let g:ctrlp_custom_ignore = '*.dat'
let g:ctrlp_extensions = ['tag', 'line']
augroup fts
autocmd BufRead,BufNewFile *.md set ft=markdown
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd Filetype html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType qf setlocal colorcolumn=0 nolist nocursorline nowrap tw=0
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd BufRead,BufNewFile *.csv setlocal ft=csv
autocmd BufRead,BufNewFile *.config set ft=xml
autocmd BufRead,BufNewFile *.master set ft=html
autocmd BufRead,BufNewFile *.ascx set ft=html
autocmd BufRead,BufNewFile *.aspx set ft=html
autocmd BufRead,BufNewFile *.ashx set ft=cs
autocmd BufRead,BufNewFile *.aspx syn region Comment start='<%--' end='--%>'
autocmd BufRead,BufNewFile *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
autocmd FileType python exec 'nnoremap <leader>ma :up<cr>:Dispatch python2 %<cr>'
autocmd BufRead,BufNewFile *.py set nocindent
autocmd FileType ruby setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType go setlocal makeprg=go\ build\ -o\ %:r.exe\ %
autocmd FileType go nnoremap <leader>ma :make<cr>:Dispatch %:r<cr>
augroup END
if has("win32")
autocmd VimEnter * :call SetDirectory()
endif
augroup Misc
au VimResized * :wincmd =
au BufWritePre * DelTrailWhitesp
au InsertLeave * set nopaste
augroup END
hi TrailingWhitespace ctermbg=red guibg=red
augroup cline
au!
au WinLeave,InsertEnter * set nocursorline
au WinLeave,InsertEnter * hi TrailingWhitespace NONE
au WinEnter,InsertLeave * set cursorline
au WinEnter,InsertLeave * hi TrailingWhitespace ctermbg=red guibg=red
augroup END
" Highlight trailing whitespace
match TrailingWhitespace /\S\zs\s\+$/
function! DelTrailWhitesp()
if search('\s\+$', 'np')
silent! %s/\s\+$//e | silent! norm ``zz
endif
endfunction
command! -nargs=0 DelTrailWhitesp :call DelTrailWhitesp()
" tpope's OpenURL function
function! OpenURL(url)
if has("win32")
exe "!start cmd /cstart /b ".a:url.""
elseif $DISPLAY !~ '^\w'
exe "silent !sensible-browser \"".a:url."\""
else
exe "silent !sensible-browser -T \"".a:url."\""
endif
redraw!
endfunction
command! -nargs=1 OpenURL :call OpenURL(<q-args>)
" open URL under cursor in browser maps
nnoremap gb :OpenURL <cfile><CR>
nnoremap gG :OpenURL http://www.google.com/search?q=<cword><CR>
nnoremap gW :OpenURL http://en.wikipedia.org/wiki/Special:Search?search=<cword><CR>
" Some number motion thing. Just trying it out. I think I found it on freenode's #vim. Anyway the
" github is github.com/sjl/dofiles
"
" Numbers {{{
"
" Motion for numbers. Great for CSS. Lets you do things like this:
"
" margin-top: 200px; -> daN -> margin-top: px;
" ^ ^
onoremap N :<c-u>call <SID>NumberTextObject(0)<cr>
xnoremap N :<c-u>call <SID>NumberTextObject(0)<cr>
onoremap aN :<c-u>call <SID>NumberTextObject(1)<cr>
xnoremap aN :<c-u>call <SID>NumberTextObject(1)<cr>
onoremap iN :<c-u>call <SID>NumberTextObject(1)<cr>
xnoremap iN :<c-u>call <SID>NumberTextObject(1)<cr>
function! s:NumberTextObject(whole)
normal! v
while getline('.')[col('.')] =~# '\v[0-9]'
normal! l
endwhile
if a:whole
normal! o
while col('.') > 1 && getline('.')[col('.') - 2] =~# '\v[0-9]'
normal! h
endwhile
endif
endfunction
" }}}