-
Notifications
You must be signed in to change notification settings - Fork 21
/
vimrc
1775 lines (1375 loc) · 42.4 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
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
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
" .vimrc
" Author: Steve Losh <steve@stevelosh.com>
" Source: http://bitbucket.org/sjl/dotfiles/src/tip/vim/
"
" This file changes a lot. I'll try to document pieces of it whenever I have
" a few minutes to kill.
" Preamble ---------------------------------------------------------------- {{{
filetype off
call pathogen#runtime_append_all_bundles()
filetype plugin indent on
set nocompatible
" }}}
" Basic options ----------------------------------------------------------- {{{
set encoding=utf-8
set modelines=0
set autoindent
set showmode
set showcmd
set hidden
set visualbell
set ttyfast
set ruler
set backspace=indent,eol,start
set nonumber
set norelativenumber
set laststatus=2
set history=1000
set undofile
set undoreload=10000
set list
set listchars=tab:▸\ ,eol:¬,extends:❯,precedes:❮
set shell=/bin/bash\ --login
set lazyredraw
set matchtime=3
set showbreak=↪
set splitbelow
set splitright
set fillchars=diff:⣿,vert:│
set autowrite
set autoread
set shiftround
set title
set linebreak
set dictionary=/usr/share/dict/words
set spellfile=~/.vim/custom-dictionary.utf-8.add
set colorcolumn=+1
" Don't try to highlight lines longer than 800 characters.
set synmaxcol=800
" Time out on key codes but not mappings.
" Basically this makes terminal Vim work sanely.
set notimeout
set ttimeout
set ttimeoutlen=10
" Make Vim able to edit crontab files again.
set backupskip=/tmp/*,/private/tmp/*"
" Better Completion
set complete=.,w,b,u,t
set completeopt=longest,menuone,preview
" Save when losing focus
au FocusLost * :silent! wall
" Resize splits when the window is resized
au VimResized * :wincmd =
" Cursorline {{{
" Only show cursorline in the current window and in normal mode.
augroup cline
au!
au WinLeave,InsertEnter * set nocursorline
au WinEnter,InsertLeave * set cursorline
augroup END
" }}}
" cpoptions+=J, dammit {{{
" Something occasionally removes this. If I manage to find it I'm going to
" comment out the line and replace all its characters with 'FUCK'.
augroup twospace
au!
au BufRead * :set cpoptions+=J
augroup END
" }}}
" Trailing whitespace {{{
" Save {{{
" augroup its2012justfuckingsavealready
" au!
" au InsertLeave * :silent! wa
" au CursorHold * :silent! wa
" au CursorHoldI * :silent! wa
" augroup END
" }}}
" Only shown when not in insert mode so I don't go insane.
augroup trailing
au!
au InsertEnter * :set listchars-=trail:⌴
augroup END
" }}}
" Wildmenu completion {{{
set wildmenu
set wildmode=list:longest
set wildignore+=.hg,.git,.svn " Version control
set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
set wildignore+=*.spl " compiled spelling word lists
set wildignore+=*.sw? " Vim swap files
set wildignore+=*.DS_Store " OSX bullshit
set wildignore+=*.luac " Lua byte code
set wildignore+=migrations " Django migrations
set wildignore+=*.pyc " Python byte code
set wildignore+=*.orig " Merge resolution files
" Clojure/Leiningen
set wildignore+=classes
set wildignore+=lib
" }}}
" Line Return {{{
" Make sure Vim returns to the same line when you reopen a file.
" Thanks, Amit
augroup line_return
au!
au BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ execute 'normal! g`"zvzz' |
\ endif
augroup END
" }}}
" Tabs, spaces, wrapping {{{
set tabstop=8
set shiftwidth=4
set softtabstop=4
set expandtab
set wrap
set textwidth=80
set formatoptions=qrn1
set colorcolumn=+1
" }}}
" Backups {{{
set backup " enable backups
set noswapfile " It's 2012, Vim.
set undodir=~/.vim/tmp/undo// " undo files
set backupdir=~/.vim/tmp/backup// " backups
set directory=~/.vim/tmp/swap// " swap files
" Make those folders automatically if they don't already exist.
if !isdirectory(expand(&undodir))
call mkdir(expand(&undodir), "p")
endif
if !isdirectory(expand(&backupdir))
call mkdir(expand(&backupdir), "p")
endif
if !isdirectory(expand(&directory))
call mkdir(expand(&directory), "p")
endif
" }}}
" Leader {{{
let mapleader = ","
let maplocalleader = "\\"
" }}}
" Color scheme {{{
syntax on
set background=dark
let g:badwolf_html_link_underline = 0
colorscheme badwolf
" Reload the colorscheme whenever we write the file.
augroup color_badwolf_dev
au!
au BufWritePost badwolf.vim color badwolf
augroup END
" Highlight VCS conflict markers
match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$'
" }}}
" }}}
" Abbreviations ----------------------------------------------------------- {{{
function! EatChar(pat)
let c = nr2char(getchar(0))
return (c =~ a:pat) ? '' : c
endfunction
function! MakeSpacelessIabbrev(from, to)
execute "iabbrev <silent> ".a:from." ".a:to."<C-R>=EatChar('\\s')<CR>"
endfunction
call MakeSpacelessIabbrev('sl/', 'http://stevelosh.com/')
call MakeSpacelessIabbrev('bb/', 'http://bitbucket.org/')
call MakeSpacelessIabbrev('bbs/', 'http://bitbucket.org/sjl/')
call MakeSpacelessIabbrev('gh/', 'http://github.com/')
call MakeSpacelessIabbrev('ghs/', 'http://github.com/sjl/')
iabbrev ldis ಠ_ಠ
iabbrev lsad ಥ_ಥ
iabbrev lhap ಥ‿ಥ
iabbrev lmis ಠ‿ಠ
iabbrev sl@ steve@stevelosh.com
iabbrev vrcf `~/.vimrc` file
iabbrev pcf Participatory Culture Foundation
inoremap <c-l> <c-k>l*
" }}}
" Convenience mappings ---------------------------------------------------- {{{
" Fuck you, help key.
noremap <F1> :set invfullscreen<CR>
inoremap <F1> <ESC>:set invfullscreen<CR>a
" Stop it, hash key.
inoremap # X<BS>#
" Kill window
nnoremap K :q<cr>
" Toggle line numbers
nnoremap <leader>n :setlocal number!<cr>
" Front and center
" Use :sus for the rare times I want to actually background Vim.
nnoremap <c-z> zvzz
vnoremap <c-z> <esc>zv`<ztgv
" Tabs
nnoremap <leader>( :tabprev<cr>
nnoremap <leader>) :tabnext<cr>
" System clipboard interaction. Mostly from:
" https://github.com/henrik/dotfiles/blob/master/vim/config/mappings.vim
noremap <leader>y "*y
noremap <leader>p :set paste<CR>"*p<CR>:set nopaste<CR>
noremap <leader>P :set paste<CR>"*P<CR>:set nopaste<CR>
vnoremap <leader>y "*ygv
" I constantly hit "u" in visual mode when I mean to "y". Use "gu" for those rare occasions.
" From https://github.com/henrik/dotfiles/blob/master/vim/config/mappings.vim
vnoremap u <nop>
vnoremap gu u
" For some reason ctags refuses to ignore Python variables, so I'll just hack
" the tags file with sed and strip them out myself.
"
" Sigh.
nnoremap <leader><cr> :silent !/usr/local/bin/ctags -R . && sed -i .bak -E -e '/^[^ ]+ [^ ]+.py .+v$/d' tags<cr>:redraw!<cr>
" Highlight Group(s)
nnoremap <F8> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<'
\ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<"
\ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>
" Clean trailing whitespace
nnoremap <leader>w mz:%s/\s\+$//<cr>:let @/=''<cr>`z
" Send visual selection to gist.github.com as a private, filetyped Gist
" Requires the gist command line too (brew install gist)
" vnoremap <leader>G :w !gist -p -t %:e \| pbcopy<cr>
" vnoremap <leader>UG :w !gist -p \| pbcopy<cr>
" Send visual selection to paste.stevelosh.com
vnoremap <c-p> :w !curl -sF 'sprunge=<-' 'http://paste.stevelosh.com' \| tr -d '\n ' \| pbcopy && open `pbpaste`<cr>
" Insert the directory of the current buffer in command line mode
cnoremap <expr> %% getcmdtype() == ':' ? expand('%:h').'/' : '%%'
" Select entire buffer
nnoremap vaa ggvGg_
nnoremap Vaa ggVG
" Change case
inoremap <C-u> <esc>mzgUiw`za
" Panic Button
nnoremap <f9> mzggg?G`z
" Emacs bindings in command line mode
cnoremap <c-a> <home>
cnoremap <c-e> <end>
" Diffoff
nnoremap <leader>D :diffoff!<cr>
" Formatting, TextMate-style
nnoremap Q gqip
vnoremap Q gq
" Reformat line.
" I never use l as a macro register anyway.
nnoremap ql ^vg_gq
" Easier linewise reselection
nnoremap <leader>V V`]
" Keep the cursor in place while joining lines
nnoremap J mzJ`z
" Split line (sister to [J]oin lines)
" The normal use of S is covered by cc, so don't worry about shadowing it.
nnoremap S i<cr><esc>^mwgk:silent! s/\v +$//<cr>:noh<cr>`w
" HTML tag closing
inoremap <C-_> <Space><BS><Esc>:call InsertCloseTag()<cr>a
" Source
vnoremap <leader>S y:execute @@<cr>:echo 'Sourced selection.'<cr>
nnoremap <leader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr>
" Marks and Quotes
noremap ' `
noremap æ '
noremap ` <C-^>
" Select (charwise) the contents of the current line, excluding indentation.
" Great for pasting Python lines into REPLs.
nnoremap vv ^vg_
" Sudo to write
cnoremap w!! w !sudo tee % >/dev/null
" Typos
command! -bang E e<bang>
command! -bang Q q<bang>
command! -bang W w<bang>
command! -bang QA qa<bang>
command! -bang Qa qa<bang>
command! -bang Wa wa<bang>
command! -bang WA wa<bang>
command! -bang Wq wq<bang>
command! -bang WQ wq<bang>
" I suck at typing.
nnoremap <localleader>= ==
vnoremap - =
" Toggle paste
set pastetoggle=<F6>
" Toggle [i]nvisible characters
nnoremap <leader>i :set list!<cr>
" Unfuck my screen
nnoremap U :syntax sync fromstart<cr>:redraw!<cr>
" Drag Lines {{{
" <m-j> and <m-k> to drag lines in any mode
noremap ∆ :m+<CR>
noremap ˚ :m-2<CR>
inoremap ∆ <Esc>:m+<CR>
inoremap ˚ <Esc>:m-2<CR>
vnoremap ∆ :m'>+<CR>gv
vnoremap ˚ :m-2<CR>gv
" }}}
" Easy filetype switching {{{
nnoremap _md :set ft=markdown<CR>
nnoremap _hd :set ft=htmldjango<CR>
nnoremap _jt :set ft=htmljinja<CR>
nnoremap _js :set ft=javascript<CR>
nnoremap _cw :set ft=confluencewiki<CR>
nnoremap _pd :set ft=python.django<CR>
nnoremap _d :set ft=diff<CR>
" }}}
" Insert Mode Completion {{{
inoremap <c-f> <c-x><c-f>
inoremap <c-]> <c-x><c-]>
" }}}
" }}}
" Quick editing ----------------------------------------------------------- {{{
nnoremap <leader>ev :vsplit $MYVIMRC<cr>
nnoremap <leader>eV :vsplit scp://vagrant//<cr>
nnoremap <leader>ef :vsplit ~/.config/fish/config.fish<cr>
nnoremap <leader>ed :vsplit ~/.vim/custom-dictionary.utf-8.add<cr>
nnoremap <leader>eo :vsplit ~/Dropbox/Org<cr>4j
nnoremap <leader>eh :vsplit ~/.hgrc<cr>
nnoremap <leader>ep :vsplit ~/.pentadactylrc<cr>
nnoremap <leader>em :vsplit ~/.mutt/muttrc<cr>
nnoremap <leader>ez :vsplit ~/lib/dotfiles/zsh<cr>4j
nnoremap <leader>ek :vsplit ~/lib/dotfiles/keymando/keymandorc.rb<cr>
nnoremap <leader>et :vsplit ~/.tmux.conf<cr>
" }}}
" Searching and movement -------------------------------------------------- {{{
" Use sane regexes.
nnoremap / /\v
vnoremap / /\v
set ignorecase
set smartcase
set incsearch
set showmatch
set hlsearch
set gdefault
set scrolloff=3
set sidescroll=1
set sidescrolloff=10
set virtualedit+=block
noremap <silent> <leader><space> :noh<cr>:call clearmatches()<cr>
runtime macros/matchit.vim
map <tab> %
" Made D behave
nnoremap D d$
" Don't move on *
nnoremap * *<c-o>
" Use c-\ to do c-] but open it in a new split.
nnoremap <c-\> <c-w>v<c-]>zvzz
" Keep search matches in the middle of the window.
nnoremap n nzzzv
nnoremap N Nzzzv
" Same when jumping around
nnoremap g; g;zz
nnoremap g, g,zz
nnoremap <c-o> <c-o>zz
" Easier to type, and I never use the default behavior.
noremap H ^
noremap L $
vnoremap L g_
" Heresy
inoremap <c-a> <esc>I
inoremap <c-e> <esc>A
" gi already moves to "last place you exited insert mode", so we'll map gI to
" something similar: move to last change
nnoremap gI `.
" Fix linewise visual selection of various text objects
nnoremap VV V
nnoremap Vit vitVkoj
nnoremap Vat vatV
nnoremap Vab vabV
nnoremap VaB vaBV
" Toggle "keep current line in the center of the screen" mode
nnoremap <leader>C :let &scrolloff=999-&scrolloff<cr>
" Directional Keys {{{
" It's 2012.
noremap j gj
noremap k gk
noremap gj j
noremap gk k
" Easy buffer navigation
noremap <C-h> <C-w>h
noremap <C-j> <C-w>j
noremap <C-k> <C-w>k
noremap <C-l> <C-w>l
noremap <leader>v <C-w>v
" }}}
" Highlight word {{{
nnoremap <silent> <leader>h1 :execute 'match InterestingWord1 /\<<c-r><c-w>\>/'<cr>
nnoremap <silent> <leader>h2 :execute '2match InterestingWord2 /\<<c-r><c-w>\>/'<cr>
nnoremap <silent> <leader>h3 :execute '3match InterestingWord3 /\<<c-r><c-w>\>/'<cr>
" }}}
" Visual Mode */# from Scrooloose {{{
function! s:VSetSearch()
let temp = @@
norm! gvy
let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g')
let @@ = temp
endfunction
vnoremap * :<C-u>call <SID>VSetSearch()<CR>//<CR><c-o>
vnoremap # :<C-u>call <SID>VSetSearch()<CR>??<CR><c-o>
" }}}
" List navigation {{{
nnoremap <left> :cprev<cr>zvzz
nnoremap <right> :cnext<cr>zvzz
nnoremap <up> :lprev<cr>zvzz
nnoremap <down> :lnext<cr>zvzz
" }}}
" }}}
" Folding ----------------------------------------------------------------- {{{
set foldlevelstart=0
" Space to toggle folds.
nnoremap <Space> za
vnoremap <Space> za
" "Refocus" folds
nnoremap ,z zMzvzz
" Make zO recursively open whatever top level fold we're in, no matter where the
" cursor happens to be.
nnoremap zO zCzO
function! MyFoldText() " {{{
let line = getline(v:foldstart)
let nucolwidth = &fdc + &number * &numberwidth
let windowwidth = winwidth(0) - nucolwidth - 3
let foldedlinecount = v:foldend - v:foldstart
" expand tabs into spaces
let onetab = strpart(' ', 0, &tabstop)
let line = substitute(line, '\t', onetab, 'g')
let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount))
let fillcharcount = windowwidth - len(line) - len(foldedlinecount)
return line . '…' . repeat(" ",fillcharcount) . foldedlinecount . '…' . ' '
endfunction " }}}
set foldtext=MyFoldText()
" }}}
" Filetype-specific ------------------------------------------------------- {{{
" C {{{
augroup ft_c
au!
au FileType c setlocal foldmethod=marker foldmarker={,}
augroup END
" }}}
" Clojure {{{
" function! SlimvToggleRepl()
" if bufname('%') ==# 'SLIMV.REPL'
" let origin = b:pop_back_to
" q
" execute "" . origin . "wincmd w"
" else
" let origin = winnr()
" vertical botright split
" e SLIMV.REPL
" let b:pop_back_to = origin
" endif
" endfunction
let g:slimv_leader = '\'
let g:slimv_keybindings = 2
augroup ft_clojure
au!
au BufNewFile,BufRead riemann.config set filetype=clojure
au FileType clojure silent! call TurnOnClojureFolding()
au FileType clojure compiler clojure
au FileType clojure setlocal report=100000
au BufWinEnter SLIMV.REPL setlocal nolist
au BufNewFile,BufReadPost SLIMV.REPL setlocal nowrap foldlevel=99
au BufNewFile,BufReadPost SLIMV.REPL nnoremap <buffer> A GA
au BufNewFile,BufReadPost SLIMV.REPL nnoremap <buffer> <localleader>R :emenu REPL.<Tab>
" Fix the eval mappings.
au FileType clojure nnoremap <buffer> <localleader>ef :<c-u>call SlimvEvalExp()<cr>
au FileType clojure nnoremap <buffer> <localleader>ee :<c-u>call SlimvEvalDefun()<cr>
" And the inspect mapping.
au FileType clojure nmap <buffer> \i \di
" And REPL-toggling mapping.
" au FileType clojure nnoremap <buffer> \rr :call SlimvToggleRepl()<cr>
" Indent top-level form.
au FileType clojure nmap <buffer> <localleader>= mz99[(v%='z
augroup END
" }}}
" Clojurescript {{{
augroup ft_clojurescript
au!
au BufNewFile,BufRead *.cljs set filetype=clojurescript
au FileType clojurescript call TurnOnClojureFolding()
" Indent top-level form.
au FileType clojurescript nmap <buffer> <localleader>= v((((((((((((=%
augroup END
" }}}
" Confluence {{{
augroup ft_c
au!
au BufRead,BufNewFile *.confluencewiki setlocal filetype=confluencewiki
" Wiki pages should be soft-wrapped.
au FileType confluencewiki setlocal wrap linebreak nolist
augroup END
" }}}
" Cram {{{
let cram_fold=1
augroup ft_cram
au!
au BufNewFile,BufRead *.t set filetype=cram
au Syntax cram setlocal foldlevel=1
au FileType cram nnoremap <buffer> <localleader>ee :e<cr>
augroup END
" }}}
" CSS and LessCSS {{{
augroup ft_css
au!
au BufNewFile,BufRead *.less setlocal filetype=less
au Filetype less,css setlocal foldmethod=marker
au Filetype less,css setlocal foldmarker={,}
au Filetype less,css setlocal omnifunc=csscomplete#CompleteCSS
au Filetype less,css setlocal iskeyword+=-
" Use <leader>S to sort properties. Turns this:
"
" p {
" width: 200px;
" height: 100px;
" background: red;
"
" ...
" }
"
" into this:
" p {
" background: red;
" height: 100px;
" width: 200px;
"
" ...
" }
au BufNewFile,BufRead *.less,*.css nnoremap <buffer> <localleader>S ?{<CR>jV/\v^\s*\}?$<CR>k:sort<CR>:noh<CR>
" Make {<cr> insert a pair of brackets in such a way that the cursor is correctly
" positioned inside of them AND the following code doesn't get unfolded.
au BufNewFile,BufRead *.less,*.css inoremap <buffer> {<cr> {}<left><cr><space><space><space><space>.<cr><esc>kA<bs>
augroup END
" }}}
" Django {{{
augroup ft_django
au!
au BufNewFile,BufRead urls.py setlocal nowrap
au BufNewFile,BufRead urls.py normal! zR
au BufNewFile,BufRead dashboard.py normal! zR
au BufNewFile,BufRead local_settings.py normal! zR
au BufNewFile,BufRead admin.py setlocal filetype=python.django
au BufNewFile,BufRead urls.py setlocal filetype=python.django
au BufNewFile,BufRead models.py setlocal filetype=python.django
au BufNewFile,BufRead views.py setlocal filetype=python.django
au BufNewFile,BufRead settings.py setlocal filetype=python.django
au BufNewFile,BufRead settings.py setlocal foldmethod=marker
au BufNewFile,BufRead forms.py setlocal filetype=python.django
au BufNewFile,BufRead common_settings.py setlocal filetype=python.django
au BufNewFile,BufRead common_settings.py setlocal foldmethod=marker
augroup END
" }}}
" Firefox {{{
augroup ft_firefox
au!
au BufRead,BufNewFile ~/Library/Caches/*.html setlocal buftype=nofile
augroup END
" }}}
" Fish {{{
augroup ft_fish
au!
au BufNewFile,BufRead *.fish setlocal filetype=fish
au FileType fish setlocal foldmethod=marker foldmarker={{{,}}}
augroup END
" }}}
" Haskell {{{
augroup ft_haskell
au!
au BufEnter *.hs compiler ghc
augroup END
" }}}
" HTML and HTMLDjango {{{
let g:html_indent_tags = ['p', 'li']
augroup ft_html
au!
au BufNewFile,BufRead *.html setlocal filetype=htmldjango
au FileType html,jinja,htmldjango setlocal foldmethod=manual
" Use <localleader>f to fold the current tag.
au FileType html,jinja,htmldjango nnoremap <buffer> <localleader>f Vatzf
" Use <localleader>t to fold the current templatetag.
au FileType html,jinja,htmldjango nmap <buffer> <localleader>t viikojozf
" Indent tag
au FileType html,jinja,htmldjango nnoremap <buffer> <localleader>= Vat=
" Django tags
au FileType jinja,htmldjango inoremap <buffer> <c-t> {%<space><space>%}<left><left><left>
" Django variables
au FileType jinja,htmldjango inoremap <buffer> <c-f> {{<space><space>}}<left><left><left>
augroup END
" }}}
" Java {{{
augroup ft_java
au!
au FileType java setlocal foldmethod=marker
au FileType java setlocal foldmarker={,}
augroup END
" }}}
" Javascript {{{
augroup ft_javascript
au!
au FileType javascript setlocal foldmethod=marker
au FileType javascript setlocal foldmarker={,}
" Make {<cr> insert a pair of brackets in such a way that the cursor is correctly
" positioned inside of them AND the following code doesn't get unfolded.
au Filetype javascript inoremap <buffer> {<cr> {}<left><cr><space><space><space><space>.<cr><esc>kA<bs>
augroup END
" }}}
" Lisp {{{
augroup ft_lisp
au!
au FileType lisp call TurnOnLispFolding()
augroup END
" }}}
" Mail {{{
augroup ft_mail
au!
au Filetype mail setlocal spell
augroup END
" }}}
" Markdown {{{
augroup ft_markdown
au!
au BufNewFile,BufRead *.m*down setlocal filetype=markdown
" Use <localleader>1/2/3 to add headings.
au Filetype markdown nnoremap <buffer> <localleader>1 yypVr=:redraw<cr>
au Filetype markdown nnoremap <buffer> <localleader>2 yypVr-:redraw<cr>
au Filetype markdown nnoremap <buffer> <localleader>3 mzI###<space>`zllll <ESC>
augroup END
" }}}
" Mercurial {{{
augroup ft_mercurial
au!
au BufNewFile,BufRead *hg-editor-*.txt setlocal filetype=hgcommit
augroup END
" }}}
" Mutt {{{
augroup ft_muttrc
au!
au BufRead,BufNewFile *.muttrc set ft=muttrc
au FileType muttrc setlocal foldmethod=marker foldmarker={{{,}}}
augroup END
" }}}
" Nginx {{{
augroup ft_nginx
au!
au BufRead,BufNewFile /etc/nginx/conf/* set ft=nginx
au BufRead,BufNewFile /etc/nginx/sites-available/* set ft=nginx
au BufRead,BufNewFile /usr/local/etc/nginx/sites-available/* set ft=nginx
au BufRead,BufNewFile vhost.nginx set ft=nginx
au FileType nginx setlocal foldmethod=marker foldmarker={,}
augroup END
" }}}
" OrgMode {{{
augroup ft_org
au!
au Filetype org nmap <buffer> Q vahjgq
au Filetype org setlocal nolist
augroup END
" }}}
" Pentadactyl {{{
augroup ft_pentadactyl
au!
au BufNewFile,BufRead .pentadactylrc set filetype=pentadactyl
au BufNewFile,BufRead ~/Library/Caches/TemporaryItems/pentadactyl-*.tmp set nolist wrap linebreak columns=100 colorcolumn=0
augroup END
" }}}
" Puppet {{{
augroup ft_puppet
au!
au Filetype puppet setlocal foldmethod=marker
au Filetype puppet setlocal foldmarker={,}
augroup END
" }}}
" Python {{{
augroup ft_python
au!
au FileType python setlocal define=^\s*\\(def\\\\|class\\)
au FileType man nnoremap <buffer> <cr> :q<cr>
" Jesus tapdancing Christ, built-in Python syntax, you couldn't let me
" override this in a normal way, could you?
au FileType python if exists("python_space_error_highlight") | unlet python_space_error_highlight | endif
" Jesus, Python. Five characters of punctuation for a damn string?
au FileType python inoremap <buffer> <c-g> _(u'')<left><left>
au FileType python inoremap <buffer> <c-b> """"""<left><left><left>
augroup END
" }}}
" QuickFix {{{
augroup ft_quickfix
au!
au Filetype qf setlocal colorcolumn=0 nolist nocursorline nowrap tw=0
augroup END
" }}}
" ReStructuredText {{{
augroup ft_rest
au!
au Filetype rst nnoremap <buffer> <localleader>1 yypVr=:redraw<cr>
au Filetype rst nnoremap <buffer> <localleader>2 yypVr-:redraw<cr>
au Filetype rst nnoremap <buffer> <localleader>3 yypVr~:redraw<cr>
au Filetype rst nnoremap <buffer> <localleader>4 yypVr`:redraw<cr>
augroup END
" }}}
" Riemann Config Files {{{
augroup ft_riemann
au!
au BufNewFile,BufRead riemann.config set filetype=clojure
au BufNewFile,BufRead riemann.config nnoremap <buffer> <localleader>= mzgg=G`z
augroup END
" }}}
" Ruby {{{
augroup ft_ruby
au!
au Filetype ruby setlocal foldmethod=syntax
augroup END
" }}}
" stevelosh.com Blog Entries {{{
augroup ft_steveloshcom
au!
au BufRead,BufNewFile */stevelosh/content/blog/20*/*/*.html set ft=markdown spell
au BufRead,BufNewFile */stevelosh/content/projects/*.html set ft=markdown spell
augroup END
" }}}
" Vagrant {{{
augroup ft_vagrant
au!
au BufRead,BufNewFile Vagrantfile set ft=ruby
augroup END
" }}}
" Vim {{{
augroup ft_vim
au!
au FileType vim setlocal foldmethod=marker
au FileType help setlocal textwidth=78
au BufWinEnter *.txt if &ft == 'help' | wincmd L | endif
augroup END
" }}}
" }}}
" Plugin settings --------------------------------------------------------- {{{
" Ack {{{
nnoremap <leader>a :Ack!<space>
let g:ackprg = 'ag --nogroup --nocolor --column'
" }}}
" Autoclose {{{
nmap <Leader>x <Plug>ToggleAutoCloseMappings
" }}}
" Clam {{{
nnoremap ! :Clam<space>
vnoremap ! :ClamVisual<space>
let g:clam_autoreturn = 1
let g:clam_debug = 1