-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvimrc
1510 lines (1202 loc) · 39.1 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
" Preamble ---------------------------------------------------------------- {{{
set nocompatible
filetype off " required!
" pathogen disabled
" call pathogen#infect('~/.vim/local/bundle/')
set rtp+=~/.vim/local/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle
" required!
Plugin 'VundleVim/Vundle.vim'
" }}}
" Plugins ----------------------------------------------------------------- {{{
" (Help) Manage bundles {{{
" Brief help
" :PluginList - list configured bundles
" :PluginInstall(!) - install(update) bundles
" :PluginSearch(!) foo - search(or refresh cache first) for foo
" :PluginClean(!) - confirm(or auto-approve) removal of unused bundles
"
" see :h vundle for more details or wiki for FAQ
" NOTE: comments after Plugin command are not allowed..
" }}}
" General {{{
" original repos on github
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-unimpaired'
Plugin 'tpope/vim-repeat'
Plugin 'tpope/vim-commentary'
Plugin 'scrooloose/nerdtree'
" Plugin 'scrooloose/nerdcommenter'
" abolish.vim: easily search for, substitute,
" and abbreviate multiple variants of a word
Plugin 'tpope/vim-abolish'
" speeddating.vim: use CTRL-A/CTRL-X to increment dates, times, and more
Plugin 'tpope/vim-speeddating'
Plugin 'korpz/Autoclose-vim'
Plugin 'Lokaltog/vim-easymotion'
Plugin 'sjl/gundo.vim'
" Perform all your vim insert mode completions with Tab
Plugin 'ervandew/supertab'
" Plugin to create and use a scratch Vim buffer
Plugin 'vim-scripts/scratch.vim'
" Text outlining and task management for Vim based on Emacs' Org-Mode
Plugin 'jceb/vim-orgmode'
" Maintains a history of previous yanks, changes and deletes
" Plugin 'chrismetcalf/vim-yankring'
" Maximizer lets you maximize split windows and restore them automatically
Plugin 'szw/vim-maximizer'
"
" }}}
" Development {{{
" Git
Plugin 'tpope/vim-fugitive'
" VCS changes signs
Plugin 'mhinz/vim-signify'
" Gist
Plugin 'mattn/gist-vim'
" A Vim plugin for resolving three-way merges.
Plugin 'sjl/threesome.vim'
" Source code browser with excellent support for Javascript
Plugin 'taglist-plus'
" Vim plugin that displays tags in a window, ordered by class etc.
Plugin 'majutsushi/tagbar'
" MakeGreen runs make and shows a red or green message bar
" for success/failure. Speeds the red-green-refactor cycle!
Plugin 'sjl/vim-makegreen'
" Syntax checking hacks for vim
Plugin 'scrooloose/syntastic'
" compiler for unittest by nose for python
Plugin 'lambdalisue/nose.vim'
" SML language mostly for course 'Programming languages'
Plugin 'chilicuil/vim-sml-coursera'
" }}}
" For Mac OS X only {{{
" Plugin for Vim, which provides smart keyboard layout switching.
if has('mac') || has ('macunix')
Plugin 'porqz/KeyboardLayoutSwitcher'
endif
" }}}
" For GUI only {{{
if has('gui_running')
endif
" }}}
" For Console only {{{
if !has('gui_running')
endif
" }}}
" Snippets {{{
" Code snippets engine for Vim, with snippets library.
" XPTemplate let you write codes in a smooth, quick and comfortable way.
Plugin 'drmingdrmer/xptemplate'
" snipMate.vim aims to be a concise vim script
" that implements some of TextMate's snippets features in Vim.
" Plugin 'msanders/snipmate.vim'
" The ultimate snippet solution for python enabled Vim.
" Plugin 'UltiSnips'
" }}}
" Searching {{{
Plugin 'mileszs/ack.vim'
" Plugin 'wincent/Command-T'
" Fuzzy file, buffer, mru and tag finder
Plugin 'kien/ctrlp.vim'
" }}}
" Documentation {{{
"
" Flexible viewer for any documentation source (help/man/perldoc/etc.)
" for any file type inside Vim in easy to use, consistent,
" smart and configurable way.
" Plugin 'viewdoc'
" }}}
" File specific plugins {{{
" Coffee Script {{{
" Plugin 'kchmck/vim-coffee-script'
" }}}
" CSS {{{
" Vim runtime files for Haml, Sass, and Scss
Plugin 'tpope/vim-haml'
" Highlight colors in css files
Plugin 'skammer/vim-css-color'
" vim syntax for LESS (dynamic CSS)
Plugin 'groenewege/vim-less'
" Add CSS3 syntax support to vim's built-in `syntax/css.vim`
Plugin 'hail2u/vim-css3-syntax'
" Sort css property
Plugin 'miripiruni/CSScomb-for-Vim'
" }}}
" Go {{{
Plugin 'fatih/vim-go'
" }}}
" JavaScript {{{
" Vastly improved vim's javascript indentation.
Plugin 'pangloss/vim-javascript'
" }}}
" HTML {{{
Plugin 'othree/html5.vim'
" like zen coding for vim
Plugin 'sjl/vim-sparkup'
" }}}
" Python {{{
" Plugin 'sjl/python-mode'
" }}}
" Shell {{{
" Bash
Plugin 'vim-scripts/bash-support.vim'
" }}}
" Text {{{
Plugin 'tpope/vim-markdown'
" }}}
" Puppet {{{
Plugin 'rodjek/vim-puppet'
" }}}
"
" }}}
" Visualize {{{
" colorschemes
Plugin 'altercation/vim-colors-solarized'
Plugin 'molokai'
" statusline
" Plugin 'scrooloose/vim-statline'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
" }}}
call vundle#end() " required
filetype plugin indent on " required
" }}}
" Basic options ----------------------------------------------------------- {{{
set encoding=utf-8
set modelines=0
set autoindent
set showcmd
set noshowmode
set laststatus=2
set hidden
set visualbell
set cursorline
set ttyfast
set ruler
set backspace=indent,eol,start
set number
set norelativenumber
set history=1000
set undofile
set undoreload=10000
" set cpoptions+=J
set nolist
set listchars=tab:▸\ ,eol:¬,extends:❯,precedes:❮
set shell=/bin/zsh
set lazyredraw
set matchtime=3
set showbreak=↪
set splitbelow
set splitright
set fillchars=diff:⣿,vert:│
" set ttimeout
" set notimeout
set autowrite
set shiftround
set autoread
set title
set linebreak
set dictionary=/usr/share/dict/words
" default keywordprg="man -s", but I'm prefere :help
" set keywordprg=
" Make Vim able to edit crontab files again.
set backupskip=/tmp/*"
" Save when losing focus
au FocusLost * :wa
" Resize splits when the window is resized
au VimResized * :wincmd =
" Trailing whitespace {{{
" Only shown when not in insert mode so I don't go insane.
augroup trailing
au!
au InsertEnter * :set listchars-=trail:⌴
au InsertLeave * :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=4
set shiftwidth=4
set softtabstop=4
set expandtab
set wrap
set textwidth=80
set formatoptions=qrn1
set colorcolumn=+1
" }}}
" Backups {{{
set undodir=~/.vim/tmp/undo// " undo files
set backupdir=~/.vim/tmp/backup// " backups
set directory=~/.vim/tmp/swap// " swap files
set backup " enable backups
set noswapfile " It's 2012, Vim.
" }}}
" Leader {{{
let mapleader = ";"
let maplocalleader = ","
" }}}
" Color scheme {{{
syntax on
set background=dark
" colorscheme molokai
colorscheme molokai
" 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 al@ alex@alexlov.com
iabbrev vrcf `~/.vimrc` file
" }}}
" 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 <leader><space> :noh<cr>:call clearmatches()<cr>
runtime macros/matchit.vim
map <tab> %
" Made D behave
nnoremap D d$
" Keep search matches in the middle of the window and pulse the line when moving
" to them.
nnoremap n nzzzv
nnoremap N Nzzzv
" Don't move on * and #
nnoremap * *<c-o>
nnoremap # #<c-o>
" Same when jumping around
nnoremap g; g;zz
nnoremap g, g,zz
" Window resizing
" nnoremap <c-left> 5<c-w>>
" nnoremap <c-right> 5<c-w><
" Easier to type, and I never use the default behavior.
" noremap H ^
" noremap L g_
" Heresy
inoremap <c-a> <esc>I
inoremap <c-e> <esc>A
" Open a Quickfix window for the last search.
nnoremap <silent> <leader>/ :execute 'vimgrep /'.@/.'/g %'<CR>:copen<CR>
" Ack for the last search.
" nnoremap <silent> <leader>? :execute "Ack! '" . substitute(substitute(substitute(@/, "\\\\<", "\\\\b", ""), "\\\\>", "\\\\b", ""), "\\\\v", "", "") . "'"<CR>
" Directional Keys {{{
" It's 2011.
noremap j gj
noremap k gk
" 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 <C-tab> <C-w>w
noremap <C-S-tab> <C-w>W
noremap <leader>h <C-w>s
noremap <leader>v <C-w>v
" }}}
" Highlight word {{{
" nnoremap <silent> <leader>hh :execute 'match InterestingWord1 /\<<c-r><c-w>\>/'<cr>
" 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>
" }}}
" }}}
" Folding ----------------------------------------------------------------- {{{
set foldlevelstart=0
" set foldcrlumn=3
" Make the current location sane.
nnoremap <c-cr> zvzt
" Space to toggle folds.
nnoremap <Space> za
vnoremap <Space> za
" Make zO recursively open whatever top level fold we're in, no matter where the
" cursor happens to be.
nnoremap zO zCzO
" Use ;z to "focus" the current fold.
nnoremap <leader>z zMzvzz
function! MyFoldText() " {{{
let line = getline(v:foldstart)
let level = repeat("-", v:foldlevel)
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) - 3 - v:foldlevel
return '+' . level . line . '… ' . repeat(" ",fillcharcount) . foldedlinecount . '…' . ' '
" return line . '…' . repeat(" ",fillcharcount) . foldedlinecount . '…' . ' '
endfunction " }}}
set foldtext=MyFoldText()
" }}}
" Destroy infuriating keys ------------------------------------------------ {{{
" Fuck you, help key.
" noremap <F1> :set invfullscreen<CR>
" inoremap <F1> <ESC>:set invfullscreen<CR>a
" Fuck you too, manual key.
" nnoremap K <nop>
" Stop it, hash key.
" inoremap # X<BS>#
" }}}
" Various filetype-specific stuff ----------------------------------------- {{{
" C {{{
augroup ft_c
au!
au FileType c setlocal foldmethod=syntax
augroup END
" }}}
" Clojure {{{
" let g:slimv_leader = '\'
" let g:slimv_keybindings = 2
" augroup ft_clojure
" au!
" au FileType clojure call TurnOnClojureFolding()
" au FileType clojure compiler clojure
" au FileType clojure setlocal report=100000
" au BufWinEnter SLIMV.REPL setlocal winfixwidth 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
" " Indent top-level form.
" au FileType clojure nmap <buffer> <localleader>= v((((((((((((=%
" augroup END
" }}}
" Clojurescript {{{
" augroup ft_clojurescript
" au!
" au BufNewFile,BufRead *.cljs set filetype=clojurescript
" au FileType clojurescript call TurnOnClojureFolding()
" " Send current toplevel form to dtach.
" au FileType clojurescript nnoremap <buffer> \ee mz:call SelectToplevelForm()<cr>:call SendToDtach(1)<cr>`z
" 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
augroup END
" }}}
" CSS and LessCSS and SASS ans SCSS {{{
augroup ft_css
au!
au BufNewFile,BufRead *.less setlocal filetype=less
au Filetype less,css,sass,scss setlocal foldmethod=marker
au Filetype less,css,sass,scss setlocal foldmarker={,}
au Filetype less,css,sass,scss setlocal omnifunc=csscomplete#CompleteCSS
au Filetype less,css,sass,scss setlocal iskeyword+=-
au Filetype less,css,sass,scss setlocal sts=2 sw=2 ts=2
" Use <localleader>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,*.sass,*.scss 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,*.scss inoremap <buffer> {<cr> {}<left><cr><cr><esc>kA<bs>
"
" CSSComb
nnoremap <bufer> <localleader>S :CSSComb<cr>
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
augroup END
" }}}
" Haskell {{{
augroup ft_haskell
au!
au BufEnter *.hs compiler ghc
augroup END
" }}}
" HTML and HTMLDjango {{{
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
" Use Shift-Return to turn this:
" <tag>|</tag>
"
" into this:
" <tag>
" |
" </tag>
au FileType html,jinja,htmldjango nnoremap <buffer> <s-cr> vit<esc>a<cr><esc>vito<esc>i<cr><esc>
" Smarter pasting
" au FileType html,jinja,htmldjango nnoremap <buffer> p :<C-U>YRPaste 'p'<CR>v`]=`]
" au FileType html,jinja,htmldjango nnoremap <buffer> P :<C-U>YRPaste 'P'<CR>v`]=`]
" au FileType html,jinja,htmldjango nnoremap <buffer> π :<C-U>YRPaste 'p'<CR>
" au FileType html,jinja,htmldjango nnoremap <buffer> ∏ :<C-U>YRPaste 'P'<CR>
" 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=
au Filetype markdown nnoremap <buffer> <localleader>2 yypVr-
au Filetype markdown nnoremap <buffer> <localleader>3 I### <ESC>
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={,}
au Filetype puppet setlocal ts=2 sts=2 sw=2
augroup END
" }}}
" Python {{{
augroup ft_python
au!
" au FileType python setlocal omnifunc=pythoncomplete#Complete
au FileType python setlocal define=^\s*\\(def\\\\|class\\)
au FileType python compiler nose
" 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> <d-'> _(u'')<left><left>
augroup END
" }}}
" QuickFix {{{
augroup ft_quickfix
au!
au Filetype qf setlocal colorcolumn=0 nolist nocursorline nowrap
augroup END
" }}}
" ReStructuredText {{{
augroup ft_rest
au!
au Filetype rst nnoremap <buffer> <localleader>1 yypVr=
au Filetype rst nnoremap <buffer> <localleader>2 yypVr-
au Filetype rst nnoremap <buffer> <localleader>3 yypVr~
au Filetype rst nnoremap <buffer> <localleader>4 yypVr`
augroup END
" }}}
" Ruby {{{
augroup ft_ruby
au!
au Filetype ruby setlocal foldmethod=syntax
augroup END
" }}}
" Scheme {{{
" augroup ft_scheme
" au!
" " Send current toplevel form to dtach.
" au FileType scheme nnoremap <buffer> \ee mz:call SelectToplevelForm()<cr>:call SendToDtach(1)<cr>`z
" 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
" }}}
" YAML {{{
augroup ft_yaml
au!
au FileType yaml setlocal tabstop=2 softtabstop=2 shiftwidth=2
augroup END
" }}}
" }}}
" Quick editing ----------------------------------------------------------- {{{
nnoremap <leader>ev <C-w>v<C-w>j:e $MYVIMRC<cr>
"nnoremap <leader>es <C-w>v<C-w>j:e ~/.vim/snippets/<cr>
"nnoremap <leader>eo <C-w>v<C-w>j:e ~/Dropbox/Org<cr>4j
"nnoremap <leader>eh <C-w>v<C-w>j:e ~/.hgrc<cr>
"nnoremap <leader>ep <C-w>v<C-w>j:e ~/.pentadactylrc<cr>
"nnoremap <leader>em <C-w>v<C-w>j:e ~/.mutt/muttrc<cr>
"nnoremap <leader>ez <C-w>v<C-w>j:e ~/lib/dotfiles/zsh<cr>4j
"nnoremap <leader>ek <C-w>v<C-w>j:e ~/lib/dotfiles/keymando/keymandorc.rb<cr>
" }}}
" Shell ------------------------------------------------------------------- {{{
function! s:ExecuteInShell(command) " {{{
let command = join(map(split(a:command), 'expand(v:val)'))
let winnr = bufwinnr('^' . command . '$')
silent! execute winnr < 0 ? 'botright vnew ' . fnameescape(command) : winnr . 'wincmd w'
setlocal buftype=nowrite bufhidden=wipe nobuflisted noswapfile nowrap nonumber
echo 'Execute ' . command . '...'
silent! execute 'silent %!'. command
silent! redraw
silent! execute 'au BufUnload <buffer> execute bufwinnr(' . bufnr('#') . ') . ''wincmd w'''
silent! execute 'nnoremap <silent> <buffer> <LocalLeader>r :call <SID>ExecuteInShell(''' . command . ''')<CR>:AnsiEsc<CR>'
silent! execute 'nnoremap <silent> <buffer> q :q<CR>'
silent! execute 'AnsiEsc'
echo 'Shell command ' . command . ' executed.'
endfunction " }}}
command! -complete=shellcmd -nargs=+ Shell call s:ExecuteInShell(<q-args>)
nnoremap <leader>! :Shell
" }}}
" Dim inactive windows using 'colorcolumn' setting ------------------------ {{{
" This tends to slow down redrawing, but is very useful.
" Based on https://groups.google.com/d/msg/vim_use/IJU-Vk-QLJE/xz4hjPjCRBUJ
" XXX: this will only work with lines containing text (i.e. not '~')
function! s:DimInactiveWindows() " {{{
for i in range(1, tabpagewinnr(tabpagenr(), '$'))
let l:range = ""
if i != winnr()
if &wrap
" HACK: when wrapping lines is enabled, we use the maximum number
" of columns getting highlighted. This might get calculated by
" looking for the longest visible line and using a multiple of
" winwidth().
let l:width=256 " max
else
let l:width=winwidth(i)
endif
let l:range = join(range(1, l:width), ',')
endif
call setwinvar(i, '&colorcolumn', l:range)
endfor
endfunction " }}}
augroup DimInactiveWindows
hi ColorColumn ctermbg=234 guibg=#293739
au!
au WinEnter * call s:DimInactiveWindows()
au WinEnter * set cursorline
au WinLeave * set nocursorline
augroup END
" }}}
" Convenience mappings ---------------------------------------------------- {{{
" Clean trailing whitespace
nnoremap <leader>ts :%s/\s\+$//<cr>:let @/=''<cr>
" Change case
nnoremap <C-u> g~iw
inoremap <C-u> <esc>g~iwea
" Substitute
nnoremap <leader>f :%s//<left>
" Emacs bindings in command line mode
cnoremap <c-a> <home>
cnoremap <c-e> <end>
cnoremap <c-h> <left>
cnoremap <c-l> <right>
" Diffoff
nnoremap <leader>D :diffoff!<cr>
" Formatting, TextMate-style
nnoremap Q gqip
vnoremap Q gq
" Easier linewise reselection
nnoremap <leader>V V`]
" 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><right>mwgk:silent! s/\v +$//<cr>:noh<cr>`w
" HTML tag closing
" inoremap <C-_> <Space><BS><Esc>:call InsertCloseTag()<cr>a
" Align text
nnoremap <leader>Al :left<cr>
nnoremap <leader>Ac :center<cr>
nnoremap <leader>Ar :right<cr>
vnoremap <leader>Al :left<cr>
vnoremap <leader>Ac :center<cr>
vnoremap <leader>Ar :right<cr>
" I'm too lazy for Shift-;
nnoremap ;; :
" Cmdheight switching
nnoremap <leader>1 :set cmdheight=1<cr>
nnoremap <leader>2 :set cmdheight=2<cr>
" Source
" vnoremap <leader>S y:execute @@<cr>