-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.vund_vimrc
798 lines (687 loc) · 20.3 KB
/
.vund_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
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
" =======================================
" Who:
" What:
" Version:
" =======================================
set nocompatible " be iMproved
filetype off " required!
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'gmarik/vundle'
Bundle 'ZoomWin'
Bundle 'wincent/Command-T'
Bundle 'christoomey/vim-space'
Bundle 'Lokaltog/vim-easymotion'
Bundle 'kien/ctrlp.vim'
Bundle 'mutewinter/vim-indent-guides'
Bundle 'Lokaltog/vim-powerline'
Bundle 'scrooloose/nerdtree'
Bundle 'Rykka/colorv.vim'
Bundle 'nanotech/jellybeans.vim'
Bundle 'tomtom/quickfixsigns_vim'
Bundle 'scrooloose/nerdcommenter'
Bundle 'tpope/vim-surround'
Bundle 'tpope/vim-speeddating'
Bundle 'tpope/vim-fugitive'
Bundle 'godlygeek/tabular'
Bundle 'mileszs/ack.vim'
Bundle 'gmarik/sudo-gui.vim'
Bundle 'milkypostman/vim-togglelist'
Bundle 'mutewinter/swap-parameters'
Bundle 'keepcase.vim'
Bundle 'scratch.vim'
Bundle 'mattn/zencoding-vim'
Bundle 'mutewinter/GIFL'
Bundle 'swaroopch/vim-markdown-preview'
Bundle 'IndexedSearch'
Bundle 'xolox/vim-session'
Bundle 'Raimondi/delimitMate'
Bundle 'scrooloose/syntastic'
Bundle 'ervandew/supertab'
Bundle 'gregsexton/MatchTag'
Bundle 'Shougo/neocomplcache'
Bundle 'vim-ruby/vim-ruby'
Bundle 'tpope/vim-haml'
Bundle 'tpope/vim-rails'
Bundle 'tpope/vim-rake'
Bundle 'pangloss/vim-javascript'
Bundle 'kchmck/vim-coffee-script'
Bundle 'leshill/vim-json'
Bundle 'itspriddle/vim-jquery'
Bundle 'nono/vim-handlebars'
Bundle 'mutewinter/tomdoc.vim'
Bundle 'jc00ke/vim-tomdoc'
Bundle 'msanders/cocoa.vim'
Bundle 'mutewinter/taskpaper.vim'
Bundle 'mutewinter/nginx.vim'
Bundle 'timcharper/textile.vim'
Bundle 'ChrisYip/Better-CSS-Syntax-for-Vim'
Bundle 'acustodioo/vim-tmux'
Bundle 'hallison/vim-markdown'
Bundle 'xhtml.vim--Grny'
Bundle 'groenewege/vim-less'
Bundle 'matchit.zip'
Bundle 'kana/vim-textobj-user'
Bundle 'nelstrom/vim-textobj-rubyblock'
Bundle 'L9'
Bundle 'tpope/vim-repeat'
Bundle 'mathml.vim'
Bundle 'tpope/vim-endwise'
Bundle 'vim-scripts/YankRing.vim'
Bundle 'tomtom/quickfixsigns_vim'
Bundle 'fholgado/minibufexpl.vim'
Bundle 'MarcWeber/vim-addon-mw-utils'
Bundle 'tomtom/tlib_vim'
Bundle 'honza/snipmate-snippets'
Bundle 'garbas/vim-snipmate'
Bundle 'rodjek/vim-puppet'
" Automatically detect file types. (must turn on after Vundle)
filetype plugin indent on
" Set leader to ,
" Note: This line MUST come before any <leader> mappings
let mapleader=","
" ----------------------------------------
" Platform Specific Configuration
" ----------------------------------------
if has('win32') || has('win64')
" Windows
source $VIMRUNTIME/mswin.vim
set guifont=Consolas:h10
set guioptions-=T " Toolbar
set guioptions-=m " Menubar
" Set height and width on Windows
set lines=60
set columns=120
" Windows has a nasty habit of launching gVim in the wrong working directory
cd ~
elseif has('gui_macvim')
" MacVim
" Custom Menlo font for Powerline
" From: https://github.com/Lokaltog/vim-powerline/wiki/Patched-fonts
set guifont=Menlo\ for\ Powerline:h12
" Hide Toolbar in MacVim
if has("gui_running")
set guioptions=egmrt
endif
" Use option (alt) as meta key.
set macmeta
endif
" ----------------------------------------
" Regular Vim Configuration (No Plugins Needed)
" ----------------------------------------
" ---------------
" Color
" ---------------
set background=dark
colorscheme jellybeans
" ---------------
" Backups
" ---------------
set backup
set backupdir=~/.vim/backup
set directory=~/.vim/tmp
" ---------------
" UI
" ---------------
set ruler " Ruler on
set nu " Line numbers on
set nowrap " Line wrapping off
set laststatus=2 " Always show the statusline
set cmdheight=2 " Make the command area two lines high
set encoding=utf-8
if exists('+colorcolumn')
set colorcolumn=80 " Color the 80th column differently
endif
" Disable tooltips for hovering keywords in Vim
if exists('+ballooneval')
" This doesn't seem to stop tooltips for Ruby files
set noballooneval
" 100 second delay seems to be the only way to disable the tooltips
set balloondelay=100000
endif
" ---------------
" Behaviors
" ---------------
syntax enable
set autoread " Automatically reload changes if detected
set wildmenu " Turn on WiLd menu
set hidden " Change buffer - without saving
set history=768 " Number of things to remember in history.
set cf " Enable error files & error jumping.
set clipboard+=unnamed " Yanks go on clipboard instead.
set autowrite " Writes on make/shell commands
set timeoutlen=350 " Time to wait for a command (after leader for example)
set foldlevelstart=99 " Remove folds
set formatoptions=crql
set iskeyword+=$,@ " Add extra characters that are valid parts of variables
" ---------------
" Text Format
" ---------------
set tabstop=2
set backspace=2 " Delete everything with backspace
set shiftwidth=2 " Tabs under smart indent
set cindent
set autoindent
set smarttab
set expandtab
" ---------------
" Searching
" ---------------
set ignorecase " Case insensitive search
set smartcase " Non-case sensitive search
set incsearch
set hlsearch
set wildignore+=*.o,*.obj,*.exe,*.so,*.dll,*.pyc,.svn,.hg,.bzr,.git,
\.sass-cache,*.class,*.scssc,*.cssc,sprockets%*,*.lessc
" ---------------
" Visual
" ---------------
set showmatch " Show matching brackets.
set matchtime=2 " How many tenths of a second to blink
" Show invisible characters
set list
" Show trailing spaces as dots and carrots for extended lines.
" From Janus, http://git.io/PLbAlw
" Reset the listchars
set listchars=""
" a tab should display as " ", trailing whitespace as "."
set listchars=tab:▸\ " Indentended trailing whitespace
" show trailing spaces as dots
set listchars+=trail:•
" The character to show in the last column when wrap is off and the line
" continues beyond the right of the screen
set listchars+=extends:»
" The character to show in the last column when wrap is off and the line
" continues beyond the right of the screen
set listchars+=precedes:«
" ---------------
" Sounds
" ---------------
set noerrorbells
set novisualbell
set t_vb=
" ---------------
" Mouse
" ---------------
set mousehide " Hide mouse after chars typed
set mouse=a " Mouse in all modes
" Better complete options to speed it up
set complete=.,w,b,u,U,t,i,d
" ----------------------------------------
" Bindings
" ----------------------------------------
" Fixes common typos
command! W w
command! Q q
map <F1> <Esc>
imap <F1> <Esc>
" Crazy flying pinky
cnoremap w' w<CR>
" This mapping along with mapping ; to : allows for quick save with ;w;
cnoremap w; w<CR>
" Disable the ever-annoying Ex mode shortcut key. Type visual my ass.
nmap Q <nop>
" Removes doc lookup binding because it's easy to fat finger
nmap K k
vmap K k
" Make line completion easier
imap <C-l> <C-x><C-l>
" Easier Scrolling (think j/k with left hand)
" All variations are mapped for now until I get used to one
" C/M/D + d (page up)
" C/M/D + f (page down)
nmap <C-d> <C-b>
if has("gui_macvim")
nmap <D-f> <C-f>
nmap <D-d> <C-b>
else
nmap <M-f> <C-f>
nmap <M-d> <C-b>
endif
" Overrides neocomplcache with regular keyword completion
inoremap <expr><C-k> "\<C-x><C-n>"
" Use ; for : in normal and visual mode, less keystrokes
nnoremap ; :
vnoremap ; :
" double percentage sign in command mode is expanded
" to directory of current file - http://vimcasts.org/e/14
cnoremap %% <C-R>=expand('%:h').'/'<cr>
" Yank entire buffer with gy
nmap gy :%y+<cr>
" Make Y behave like other capital commands.
" Hat-tip http://vimbits.com/bits/11
nnoremap Y y$
" ---------------
" Leader Commands
" ---------------
" Toggle spelling mode with ,s
nmap <silent> <leader>s :set spell!<CR>
" Edit vimrc with ,v
nmap <silent> <leader>v :e ~/.vim/vimrc<CR>
" Quickly switch to last buffer
nnoremap <leader>, :e#<CR>
" Window Movement
" Here's a visual guide for moving between window splits.
" 4 Window Splits
" --------
" g1 | g2
" ---|----
" g3 | g4
" -------
"
" 6 Window Splits
" -------------
" g1 | gt | g2
" ---|----|----
" g3 | gb | g4
" -------------
nmap <silent> gh :wincmd h<CR>
nmap <silent> gj :wincmd j<CR>
nmap <silent> gk :wincmd k<CR>
nmap <silent> gl :wincmd l<CR>
" Upper left window
nmap <silent> g1 :wincmd t<CR>
" Upper right window
nmap <silent> g2 :wincmd b<Bar>:wincmd k<CR>
" Lower left window
nmap <silent> g3 :wincmd t<Bar>:wincmd j<CR>
" Lower right window
nmap <silent> g4 :wincmd b<CR>
" Top Middle
nmap <silent> gu g2<Bar>:wincmd h<CR>
" Bottom Middle
nmap <silent> gd g3<Bar>:wincmd l<CR>
" Previous Window
nmap <silent> gp :wincmd p<CR>
" Equal Size Windows
nmap <silent> g= :wincmd =<CR>
" Swap Windows
nmap <silent> gx :wincmd x<CR>
" Window Splitting
nmap <silent> <leader>sh :split<CR>
nmap <silent> <leader>sv :vsplit<CR>
" Because I'm dyslexic
nmap <silent> <leader>hs :split<CR>
nmap <silent> <leader>vs :vsplit<CR>
nmap <silent> <leader>sc :close<CR>
" -----------------------------------------------------------
" The following commands are from Janus, http://git.io/_GhulA
" -----------------------------------------------------------
" Underline the current line with '='
nmap <silent> <leader>ul :t.\|s/./-/g\|:nohls<cr>
" format the entire file
nmap <leader>fef ggVG=
" ----------------------------------------
" Plugin Configuration
" ----------------------------------------
" ---------------
" space.vim
" ---------------
" Disables space mappings in select mode to fix snipMate.
let g:space_disable_select_mode=1
" ---------------
" Neocachecompl
" ---------------
let g:neocomplcache_enable_at_startup=1
let g:neocomplcache_enable_cursor_hold_i=1
let g:neocomplcache_cursor_hold_i_time=200
let g:neocomplcache_auto_completion_start_length=1
" Tab / Shift-Tab to cycle completions
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<S-TAB>"
" Required to make neocomplcache_cursor_hold_i_time work
" See https://github.com/Shougo/neocomplcache/issues/140
let s:update_time_save = &updatetime
autocmd InsertEnter * call s:on_insert_enter()
function! s:on_insert_enter()
if &updatetime > g:neocomplcache_cursor_hold_i_time
let s:update_time_save = &updatetime
let &updatetime = g:neocomplcache_cursor_hold_i_time
endif
endfunction
autocmd InsertLeave * call s:on_insert_leave()
function! s:on_insert_leave()
if &updatetime < s:update_time_save
let &updatetime = s:update_time_save
endif
endfunction
" ---------------
" Syntastic
" ---------------
let g:syntastic_enable_signs=1
let g:syntastic_auto_loc_list=1
" Platform-specific config files
if has('win32') || has('win64')
let g:syntastic_jsl_conf=$HOME.'/.vim/config/windows/syntastic/jsl.conf'
let g:syntastic_disabled_filetypes=['sh'] " Disable .sh on Windows
endif
" ---------------
" NERDTree
" ---------------
nnoremap <leader>nn :NERDTreeToggle<CR>
nnoremap <leader>nf :NERDTreeFind<CR>
let NERDTreeShowBookmarks=1
let NERDTreeIgnore=[ '\.pyc$', '\.pyo$', '\.py\$class$', '\.obj$', '\.o$', '\.so$', '\.egg$', '^\.git$' ]
let NERDTreeHighlightCursorline=1
let NERDTreeShowFiles=1
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType")
\&& b:NERDTreeType == "primary") | q | endif
" ---------------
" Indent Guides
" ---------------
let g:indent_guides_enable_on_vim_startup=1
" ---------------
" Session
" ---------------
let g:session_autosave=0
let g:session_autoload=0
nnoremap <leader>os :OpenSession<CR>
" ---------------
" SpeedDating
" ---------------
let g:speeddating_no_mappings=1 " Remove default mappings (C-a etc.)
nmap <silent><leader>dm <Plug>SpeedDatingDown
nmap <silent><leader>dp <Plug>SpeedDatingUp
nmap <silent><leader>dn <Plug>SpeedDatingNowUTC
" ---------------
" Tabular
" ---------------
nmap <Leader>t= :Tabularize /=<CR>
vmap <Leader>t= :Tabularize /=<CR>
nmap <Leader>t: :Tabularize /:\zs<CR>
vmap <Leader>t: :Tabularize /:\zs<CR>
nmap <Leader>t, :Tabularize /,\zs<CR>
vmap <Leader>t, :Tabularize /,\zs<CR>
nmap <Leader>t> :Tabularize /=>\zs<CR>
vmap <Leader>t> :Tabularize /=>\zs<CR>
nmap <Leader>t- :Tabularize /-<CR>
vmap <Leader>t- :Tabularize /-<CR>
nmap <Leader>t" :Tabularize /"<CR>
vmap <Leader>t" :Tabularize /"<CR>
" ---------------
" Fugitive
" ---------------
nmap <Leader>gc :Gcommit -v<CR>
nmap <Leader>gw :Gwrite<CR>
nmap <Leader>gs :Gstatus<CR>
nmap <Leader>gp :Git push<CR>
" Mnemonic, gu = Git Update
nmap <Leader>gu :Git pull<CR>
nmap <Leader>gd :Gdiff<CR>
" Exit a diff by closing the diff window
nmap <Leader>gx :wincmd h<CR>:q<CR>
" ---------------
" Zoomwin
" ---------------
" Zoom Window to Full Size
nmap <silent> <leader>wo :ZoomWin<CR>
" ---------------
" Command T and ctrlp.vim
" ---------------
" Ensure Ctrl-P isn't bound by default
let g:ctrlp_map = ''
" Ensure max height isn't too large. (for performance)
let g:ctrlp_max_height = 10
let g:CommandTMaxHeight = 10
" Set the default escape keybinding to, you guessed it, escape.
let g:CommandTCancelMap = '<esc>'
" Dynamically use Command T or ctrlp.vim based on availability of Ruby.
" We do this because Command T is much faster than ctrlp.vim.
if has('ruby')
" --------
" Use Command T since we've got Ruby
" --------
" Conditional Mappings
if has('unix')
nnoremap <silent><C-t> :CommandT<CR>
else
nnoremap <silent><M-t> :CommandT<CR>
endif
" Leader Commands
nnoremap <leader>t :CommandT<CR>
else
" --------
" Use ctrlp.vim since we don't have Ruby
" --------
" Conditional Mappings
if has('unix')
let g:ctrlp_map = '<C-t>'
else
let g:ctrlp_map = '<M-t>'
endif
" Leader Commands
nnoremap <leader>t :CtrlPRoot<CR>
nnoremap <leader>b :CtrlPBuffer<CR>
endif
" Always use CtrlP for most recently used files and relative dierctory.
if has('unix')
nnoremap <silent><C-u> :CtrlPCurFile<CR>
else
nnoremap <silent><M-u> :CtrlPCurFile<CR>
endif
" Also map leader commands
nnoremap <leader>u :CtrlPCurFile<CR>
nnoremap <leader>m :CtrlPMRUFiles<CR>
nnoremap <leader>b :CtrlPBuffer<CR>
" ---------------
" Powerline
" ---------------
" Keep ^B from showing on Windows in Powerline
if has('win32') || has('win64')
let g:Powerline_symbols = 'compatible'
elseif has('gui_macvim')
let g:Powerline_symbols = 'fancy'
endif
let g:Powerline_symbols = 'unicode'
call Pl#Theme#InsertSegment('ws_marker', 'after', 'lineinfo')
" ---------------
" jellybeans.vim colorscheme tweaks
" ---------------
" Make cssAttrs (center, block, etc.) the same color as units
hi! link cssAttr Constant
" ---------------
" Ack.vim
" ---------------
nmap <silent> <leader>as :AckFromSearch<CR>
" ---------------
" surround.vim
" ---------------
" Use # to get a variable interpolation (inside of a string)}
" ysiw# Wrap the token under the cursor in #{}
" Thanks to http://git.io/_XqKzQ
let g:surround_35 = "#{\r}"
" ---------------
" Gifl - Google I'm Feeling Lucky URL Grabber
" ---------------
let g:LuckyOutputFormat='markdown'
" I sometimes run vim without ruby support.
let g:GIFLSuppressRubyWarning=1
" ---------------
" swap-parameters
" ---------------
" I sometimes run vim without python support.
let g:SwapParametersSuppressPythonWarning=1
" ---------------
" Markdown-Preview
" ---------------
nmap <Leader>md :MarkdownPreview<CR>
vmap <Leader>md :MarkdownPreview<CR>
" ---------------
" Vundle
" ---------------
nmap <Leader>bi :BundleInstall<CR>
nmap <Leader>bu :BundleInstall!<CR> " Because this also updates
nmap <Leader>bc :BundleClean<CR>
" ----------------------------------------
" Functions
" ----------------------------------------
" ---------------
" OpenURL
" ---------------
if has('ruby')
ruby << EOF
require 'open-uri'
require 'openssl'
def extract_url(url)
re = %r{(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|
[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]
+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]\{\};:'"
.,<>?«»“”‘’]))}
url.match(re).to_s
end
def open_url
line = VIM::Buffer.current.line
if url = extract_url(line)
if RUBY_PLATFORM.downcase =~ /(win|mingw)(32|64)/
`start cmd /c chrome #{url}`
VIM::message("Opened #{url}")
else
`open #{url}`
VIM::message("Opened #{url}")
end
else
VIM::message("No URL found on this line.")
end
end
# Returns the contents of the <title> tag of a given page
def fetch_title(url)
if RUBY_VERSION < '1.9'
open(url).read.match(/<title>(.*?)<\/title>?/i)[1]
else
open(url, :ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE).read.
match(/<title>(.*?)<\/title>?/i)[1]
end
end
# Paste the title and url for the url on the clipboard in markdown format:
# [Title](url)
# Note: Clobbers p register
def paste_url_and_title
clipboard = VIM::evaluate('@+')
url = extract_url(clipboard)
if url and url.strip != ""
puts "Fetching title"
title = fetch_title(url)
VIM::command "let @p = '[#{title}](#{url})'"
VIM::command 'normal! "pp'
else
VIM::message("Clipboard does not contain URL: '#{clipboard[1..10]}'...")
end
end
EOF
" Open a URL
if !exists("*OpenURL")
function! OpenURL()
:ruby open_url
endfunction
endif
command! OpenUrl call OpenURL()
nnoremap <leader>o :call OpenURL()<CR>
" ---------------
" Paste link with Title
" ---------------
" Open a URL
if !exists("*PasteURLTitle")
function! PasteURLTitle()
:ruby paste_url_and_title
endfunction
endif
command! PasteURLTitle call PasteURLTitle()
map <leader>pt :PasteURLTitle<CR>
endif " endif has('ruby')
" ---------------
" Quick spelling fix (first item in z= list)
" ---------------
function! QuickSpellingFix()
if &spell
normal 1z=
else
" Enable spelling mode and do the correction
set spell
normal 1z=
set nospell
endif
endfunction
command! QuickSpellingFix call QuickSpellingFix()
nmap <silent> <leader>z :QuickSpellingFix<CR>
" ---------------
" Convert Ruby 1.8 hash rockets to 1.9 JSON style hashes.
" From: http://git.io/cxmJDw
" Note: Defaults to the entire file unless in visual mode.
" ---------------
command! -bar -range=% NotRocket execute
\'<line1>,<line2>s/:\(\w\+\)\s*=>/\1:/e' . (&gdefault ? '' : 'g')
" ---------------
" Strip Trailing White Space
" ---------------
" From http://vimbits.com/bits/377
" Preserves/Saves the state, executes a command, and returns to the saved state
function! Preserve(command)
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" Do the business:
execute a:command
" Clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endfunction
"strip all trailing white space
command! StripTrailingWhiteSpace :call Preserve("%s/\\s\\+$//e")<CR>
" ----------------------------------------
" Auto Commands
" ----------------------------------------
if has("autocmd")
" No formatting on o key newlines
autocmd BufNewFile,BufEnter * set formatoptions-=o
" No more complaining about untitled documents
autocmd FocusLost silent! :wa
" When editing a file, always jump to the last cursor position.
" This must be after the uncompress commands.
autocmd BufReadPost *
\ if line("'\"") > 1 && line ("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
" Fix trailing whitespace in my most used programming langauges
autocmd BufWritePre *.py,*.coffee,*.rb silent! :StripTrailingWhiteSpace
endif
" F2 disables paste
nnoremap <F2> :set invpaste paste?<CR>
set pastetoggle=<F2>
set showmode
" Toggle mouse usage.
nnoremap <F12> :call ToggleMouse()<CR>
function! ToggleMouse()
if &mouse == 'a'
set mouse=
echo "Mouse usage disabled"
else
set mouse=a
echo "Mouse usage enabled"
endif
endfunction
let g:yankring_history_dir = '$HOME/.vim'
let g:yankring_manual_clipboard_check = 0
nnoremap <C-y> :YRShow<cr>
"
"" Tabular
"
nmap <Leader>ah :Tabularize /=><CR>
vmap <Leader>ah :Tabularize /=><CR>
nmap <Leader>a= :Tabularize /=<CR>
vmap <Leader>a= :Tabularize /=<CR>
nmap <Leader>a: :Tabularize /:\zs<CR>
vmap <Leader>a: :Tabularize /:\zs<CR>
let g:html_indent_inctags = "html,body,head,tbody"
let g:html_indent_script1 = "inc"
let g:html_indent_style1 = "inc"
"
"" Quickfixsigns
let g:quickfixsigns_classes=['qfl', 'vcsdiff', 'breakpoints']
let g:vim_addon_manager = {
\'shell_commands_run_method': 'system',
\'auto_install': 1,
\'log_to_buf': 1,
\'log_buffer_name': '/tmp/vam_install.log',
\}
au BufWritePost * if getline(1) =~ "^#!" | if getline(1) =~ "/bin/" | silent ![ -x <afile> ] || chmod a+x <afile> | endif