-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
2908 lines (2237 loc) · 81.1 KB
/
vimrc
File metadata and controls
2908 lines (2237 loc) · 81.1 KB
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
" web resources
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" http://objectmix.com/editors/394885-how-do-you-parameterize-your-vimrc-different-machines.html
" https://github.com/bronson/vim-update-bundles
" LustyJuggler screencast: http://lococast.net/archives/185
" Command-T screencast: https://wincent.com/products/command-t
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"##############################################################################
" MEMO CARD
"##############################################################################
"
" :changes -> view undo history for buffer/file
" :history -> view history of commands
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"##############################################################################
" PATHOGEN/VUNDLE
"##############################################################################
" ---Vundle INITIALISATION------------{{{1
" This must be first, because it changes other options as side effect
set nocompatible
"" Needed on some linux distros for proper pathogen/vundle loading
"" see http://www.adamlowe.me/2009/12/vim-destroys-all-other-rails-editors.html
filetype off
""~~~ VUNDLE ~~~
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
"1}}}
" ------Load/Unload plugins RULES -----{{{1
" the VUNDLE plugin manager has to be able and manange itself
Plugin 'gmarik/vundle'
"-------------------------------------
" UNUSED
"
"-------------------------------------
" -------------------------------------
" MODULES LOADED IN ANY CASE
"
" -------------------------------------
" CSS Cleaner
Plugin 'miripiruni/CSScomb-for-Vim'
" PHP debuger
Plugin 'brookhong/DBGPavim'
" Vim Debugger
Plugin 'Decho'
" Advanced encoding detector
Plugin 'vim-scripts/FencView.vim'
" edit/post gists
Plugin 'vim-scripts/Gist.vim'
" Large files loading
Plugin 'vim-scripts/LargeFile'
" Copy / Paste with history
Plugin 'YankRing.vim'
" Vim syntax highlight for asp.net ...
Plugin 'aspnetcs'
" Resize workspace with golden ratio
Plugin 'roman/golden-ratio'
" HTML5 syntax highlight with microdata, rdf,... support
Plugin 'othree/html5.vim'
" awesome commenting plugin
Plugin 'scrooloose/nerdcommenter'
" file browser
Plugin 'scrooloose/nerdtree'
" Session handling for VIM
Plugin 'session.vim--Odding'
" Completion tool on TAB
Plugin 'ervandew/supertab'
" Syntax checking
Plugin 'scrooloose/syntastic'
" the TABULARIZE fonction for fast re-aligning of code
Plugin 'godlygeek/tabular'
" Close buffer but leave window alone : adds Kwbd command (see below)
Plugin 'cespare/vim-bclose'
" lists buffers in new tab/window (for ex)
Plugin 'jlanzarotta/bufexplorer'
" display colors inline in CSS
Plugin 'skammer/vim-css-color'
" colorscheme based on github
Plugin 'endel/vim-github-colorscheme.git'
" Tpope's GIT for vim
Plugin 'tpope/vim-fugitive'
" Tpope syntax,... for editing git related files
Plugin 'tpope/vim-git'
" JavaScript bundle provides syntax and indent plugin
Plugin 'pangloss/vim-javascript'
" syntaxe additionnelle pour vim-javascript (underscore, jquery,...)
Plugin 'crusoexia/vim-javascript-lib'
" manage Jekull blog from within Vim
Plugin 'itspriddle/vim-jekyll'
" matchit.zip : extended % matching for HTML, LaTeX, and many other languages | DEPREC ?
Plugin 'eshock/vim-matchit'
"------- STATUS LINE ------
" DISABLED (unmaintained)
"Plugin 'Lokaltog/vim-powerline'
"
" REPLACES vim-powerline
Plugin 'bling/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'edkolev/tmuxline.vim'
" ------------------------
"
" tpope,'s better repeat for vim
Plugin 'tpope/vim-repeat'
" surround by tpope
Plugin 'tpope/vim-surround'
" tpope too
Plugin 'tpope/vim-unimpaired'
" powerfull TAB templates ala textmate
Plugin 'drmingdrmer/xptemplate'
" alternate buffer explorer
Plugin 'fholgado/minibufexpl.vim'
" ----- PYTHON ------
Plugin 'klen/python-mode'
Plugin 'davidhalter/jedi-vim'
if has('python')
" Powerfull completion tool, including CTAGS (replacement for tagbar)
"Plugin 'Valloric/YouCompleteMe'
endif
" ----- JAVASCRIPT --
" jshint check for js | DEPENDS nodejs
Plugin 'wookiehangover/jshint.vim'
" insert jsdoc tags
Plugin 'heavenshell/vim-jsdoc'
" ----- SYNTAXES ----
" Syntax highlighting, matching rules and mappings for Markdown.
"Plugin 'plasticboy/vim-markdown'
" this one allows concealing of markdown markers while editing,
" and is compatible with conceiling in 'limelight' plugin.
Plugin 'tpope/vim-markdown'
" Linux only : markdown previewer
if has('unix') && !has('macunix')
Plugin 'suan/vim-instant-markdown'
endif
" syntax highlight for SCSS templates
Plugin 'cakebaker/scss-syntax.vim'
" syntax highlight for Jade templates
Plugin 'digitaltoad/vim-jade'
" Syntax highlighting for Stylus.
Plugin 'wavded/vim-stylus'
" CSV files
Plugin 'chrisbra/csv.vim'
" .toml syntax
Plugin 'cespare/vim-toml'
Plugin 'maralla/vim-toml-enhance'
" ----- TMUX ----
Plugin 'christoomey/vim-tmux-navigator'
" ----- MOVEMENT ---
"Plugin 'matze/vim-move'
" swap pane content without ruining layout
Plugin 'wesQ3/vim-windowswap'
" ------ TEXT EDITING ------
Plugin 'reedes/vim-pencil'
Plugin 'junegunn/limelight.vim'
Plugin 'junegunn/goyo.vim'
" ------ COLORSCHEMES ------
" the Solarized colorscheme
Plugin 'altercation/vim-colors-solarized'
Plugin 'junegunn/seoul256.vim'
Plugin 'reedes/vim-colors-pencil'
" colorscheme based on github
Plugin 'endel/vim-github-colorscheme.git'
" 16 color colorscheme for TTYs
Plugin 'noahfrederick/vim-noctu.git'
"-------------------------------------
" CONDITIONAL LOADING
"
"-------------------------------------
Plugin 'majutsushi/tagbar'
" TAGBAR & JAVASCRIPT : Use the 'tern' javascript ctags engine replacing the
" original doctorjs jsctags
" https://github.com/majutsushi/tagbar/wiki#javascript
" https://github.com/ramitos/jsctags (ctags generator using node 'tern')
" https://github.com/marijnh/tern_for_vim ('tern' plugin for vim)
"
" 1 : `npm install -g git+https://github.com/ramitos/jsctags.git`
" 2 : `sudo npm install tern -g` (or `npm install tern -g`on mac)
if executable('node')
if executable('jsctags')
if executable('tern')
Plugin 'marijnh/tern_for_vim'
else
"do nothing
echo "tern is not installed (ctags for javascript, read .vimrc)"
endif
else
" do nothing
echo "jsctags is not installed (ctags for javascript, read .vimrc)"
endif
endif
if has("gui_macvim")
"the PEEPOPEN program is a Macos specific Command-T
" integration with peepopen for macos
Plugin 'shemerey/vim-peepopen'
end
if v:version >= '702'
" (required by fuzzyfinder)
Plugin 'L9'
" Fuzzy file/dir/tag/... finder
Plugin 'FuzzyFinder'
endif
" All those need ruby support
if has('ruby')
" provides LustyJuggler, LustyExplorer | DEPENDS ruby
Plugin 'sjbach/lusty'
endif
if v:version >= '703' && !has('python')
" Gundo requires at least Vim 7.3
" Undo with tree, branching, history
Plugin 'Gundo'
endif
if !has("signs")
"
endif
"1}}}
" ---Vundle POST-INIT-----------------{{{1
""~~~ VUNDLE ~~~
filetype plugin indent on " required!
" "
" " Brief help
" " :BundleList - list configured bundles
" " :BundleInstall(!) - install(update) bundles
" " :BundleSearch(!) foo - search(or refresh cache first) for foo
" " :BundleClean(!) - 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..
"1}}}
"##############################################################################
" GENERAL SETTINGS
"##############################################################################
" --------GENERAL SETTINGS -------------{{{1
" UTF8 by default
set encoding=utf-8
"---------------------------------------------------------
" FROM : http://nvie.com/posts/how-i-boosted-my-vim/
" change the mapleader from \ to ,
let mapleader=","
let maplocalleader="="
" hide bufers instead of closing them
set hidden
" usefull stuff
set nowrap " don't wrap lines
set tabstop=4 " a tab is two spaces
set backspace=indent,eol,start
" allow backspacing over everything in insert mode
" (needed on some linux systems -
" cf. http://vim.wikia.com/wiki/Backspace_and_delete_problems)
set autoindent " always set autoindenting on
set copyindent " copy the previous indentation on autoindenting
set number " always show line numbers
set shiftwidth=4 " number of spaces to use for autoindenting
set shiftround " use multiple of shiftwidth when indenting with '<' and '>'
set showmatch " set show matching varenthesis
set ignorecase " ignore case when searching
set smartcase " ignore case if search pattern is all lowercase,
" case-sensitive otherwise
set smarttab " insert tabs on the start of a line according to
" shiftwidth, not tabstop
set hlsearch " highlight search terms
set incsearch " show search matches as you type
" and some more
set history=10000 " remember more commands and search history
set undodir=~/.vim/undodir " dir to store history between sessions
set undolevels=1000 " use many muchos levels of undo
set wildignore=*.swp,*.bak,*.pyc,*.class
set title " change the terminal's title
set visualbell " don't beep
set noerrorbells " don't beep
set shortmess=t " short messages in status line (filepath)
set showcmd " show abbrev command in command line as you type them
" no backups please, use git
set nobackup
set noswapfile
" See more context when scrolling
:set scrolloff=6
" Show position in lower right
":set ruler
" Better centered pipe symbol for window separation in Term & CTerm Vim
"set fillchars=vert:⏐
" Awesome TAB completion for Command Mode
" ex :colorscheme TAB to scroll through colorschemes
" map TAB to scroll through mappings
" ...
set wildmode=full
set wildmenu
set formatoptions+=croql
" Cursor : different in insert mode for terminal vim
" (with handling of tmux)
" source : https://gist.github.com/andyfowler/1195581
if has("gui")
" nothing here
else
" tmux will only forward escape sequences to the terminal if surrounded by a
" DCS sequence
" "
" http://sourceforge.net/mailarchive/forum.php?thread_name=AANLkTinkbdoZ8eNR1X2UobLTeww1jFrvfJxTMfKSq-L%2B%40mail.gmail.com&forum_name=tmux-users
"
if exists('$TMUX')
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
else
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif
endif
" REDRAW in terminal VIM each time a buffer gains focus, to prevent
" the 'ghost characters' from showing up in 'plugin heavy' situations
" (lots of system calls)
" SEE : https://unix.stackexchange.com/questions/58941/how-to-automatically-refresh-vim-on-buffer-window-focus
" ANS : https://stackoverflow.com/questions/22250690/in-terminal-vim-how-do-i-prevent-ghost-echoing-while-running-a-shell-command-vi
:au FocusGained * :redraw!
nnoremap <silent> <leader>rr :silent! redraw!<CR>
"1}}}
" --------GUI FONT & size -------------{{{1
if has("gui")
if has("gui_macvim")
" Default FONT
"set guifont=Menlo\ Regular:h11
set guifont=SourceCodePro-ExtraLight:h13
"set guifont=set guifont=DejaVu\ Sans\ Mono:h11
"set guifont=Century\ Schoolbook\ Monospace\ BT:h14
"set guifont=Nitti\ Normal:h12
nnoremap <silent> <leader>1 :silent! set guifont=Century\ Schoolbook\ Monospace\ BT:h14<CR>
nnoremap <silent> <leader>2 :silent! set guifont=DejaVu\ Sans\ Mono:h11<CR>
nnoremap <silent> <leader>3 :silent! set guifont=Menlo\ Regular:h11<CR>
nnoremap <silent> <leader>4 :silent! set guifont=Nitti\ Light:h12<CR>
nnoremap <silent> <leader>7 :silent! set guifont=Nitti\ Normal:h12<CR>
nnoremap <silent> <leader>8 :silent! set guifont=Nitti\ Bold:h12<CR>
nnoremap <silent> <leader>9 :silent! set guifont=SourceCodePro-ExtraLight:h14<CR>
else
" Default FONT
"set guifont=Century\ Schoolbook\ Monospace\ BT:h14
"set guifont=set guifont=DejaVu\ Sans\ Mono:h11
"set guifont=Menlo\ Regular:h11
set guifont="Meslo LG M DZ":10
"set guifont=Nitti\ Normal:h12
nnoremap <silent> <leader>1 :silent! set guifont=Century\ Schoolbook\ Monospace\ BT:h14<CR>
nnoremap <silent> <leader>2 :silent! set guifont=DejaVu\ Sans\ Mono:h11<CR>
nnoremap <silent> <leader>3 :silent! set guifont="Meslo LG M DZ":10<CR>
nnoremap <silent> <leader>6 :silent! set guifont=Nitti\ Light:h12<CR>
nnoremap <silent> <leader>7 :silent! set guifont=Nitti\ Normal:h12<CR>
nnoremap <silent> <leader>8 :silent! set guifont=Nitti\ Bold:h12<CR>
endif
""
"" FONTSIZE changer
"" from: http://vim.wikia.com/wiki/Change_font_size_quickly
""
"nnoremap <silent> <S-Up> :silent! let &guifont = substitute(
nnoremap <silent> <leader>= :silent! let &guifont = substitute(
\ &guifont,
\ ':h\zs\d\+',
\ '\=eval(submatch(0)+1)',
\ '')<CR>
"nnoremap <silent> <S-Down> :silent! let &guifont = substitute(
nnoremap <silent> <leader>- :silent! let &guifont = substitute(
\ &guifont,
\ ':h\zs\d\+',
\ '\=eval(submatch(0)-1)',
\ '')<CR>
endif
"1}}}
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" VIEW/SESSION
"------------------------------------------------------------------------------
" --------SessionOptions---------------{{{1
set sessionoptions=buffers,curdir,folds,localoptions,tabpages,winsize
"set sessionoptions=blank,buffers,curdir,folds,help,options,tabpages,winsize
"set sessionoptions=blank,buffers,curdir,folds,help,localoptions,options,tabpages,winsize
"1}}}
" --------View dir, options,cursor pos-{{{1
" Remember last location in file
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal g'\"" | endif
endif
" DIR to store views
set viewdir=$HOME/.vim/views
if has ("autocmd")
"automatically save a view/load it when switching buffers
"autocmd BufWinLeave * silent! mkview
"autocmd BufWinEnter * silent! loadview
""This session stuff conflicts with plugins --> disabled
""Automatically save a session when exiting VIM
"autocmd VimLeavePre * silent mksession!
endif
"" if there's a session in the working dir, load it
"silent! source Session.vim
"1}}}
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" FOLDING
"------------------------------------------------------------------------------
" --------General----------------------{{{1
set foldenable
set foldmethod=syntax
"1}}}
" --------VIM,VIMRC-------------------{{{1
if has("autocmd")
autocmd FileType vim setlocal foldmethod=marker
autocmd BufRead *.vim setlocal foldmethod=marker
autocmd FileType html setlocal foldmethod=marker
autocmd BufRead *.html setlocal foldmethod=marker
autocmd FileType jade setlocal foldmethod=marker
autocmd BufRead *.jade setlocal foldmethod=marker
autocmd BufRead *.js setlocal foldmethod=indent
endif
"au BufReadPre * setlocal foldmethod=indent
"au BufWinEnter * if &fdm == 'indent' | setlocal foldmethod=manual | endif
let g:vimsyn_folding="afmpPrt"
"1}}}
" --------BASH, SH,...-----------------{{{1
"default shell to bash
let g:is_bash=1
" fold everything please
"The syntax/sh.vim file provides several levels of syntax-based folding:
" (octal notation)
"let g:sh_fold_enabled= 0 (default, no syntax folding)
"let g:sh_fold_enabled= 1 (enable function folding)
"let g:sh_fold_enabled= 2 (enable heredoc folding)
"let g:sh_fold_enabled= 4 (enable if/do/for folding)
let g:sh_fold_enabled=7
"1}}}
" --------HTML-------------------------{{{1
" enable html tag folding with ,f
nnoremap <leader><C-space> Vatzf
"1}}}
" --------XML--------------------------{{{1
" enable html tag folding with ,f
let g:xml_syntax_folding=1
au FileType xml setlocal foldmethod=syntax
au FileType xml set tabstop=4 " a tab is four spaces for XML files
au FileType xml set shiftwidth=4 " a tab is four spaces for XML files
"1}}}
" --------Tabulation de 4--------------------------{{{1
au FileType js, cpp, python set shiftwidth=4 " a tab is four spaces for those
"1}}}
" --------Tabulation name&option-------{{{1
if version >= 700
"set showtabline to show when more than one tab
set showtabline=1
"set tab labels to show at most 12 characters
"set guitablabel=%-0.12t%M
endif
" don't show the toolbar in the GUI (only the menu)
set guioptions-=T
" don't show tear-off menus
"set guioptions-=t
"1}}}
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" SPELLCHECK
"------------------------------------------------------------------------------
"
set nospell
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" INDENTATION
"------------------------------------------------------------------------------
" --------Expantab---------------------{{{1
" filetype detection, plugin and indent : ON
filetype plugin indent on
set expandtab "soft tabs, except for languages where it makes sense (python)
" actually show tabs for specific files
if has('autocmd')
" make use real tabs
autocmd FileType make set noexpandtab
endif
"1}}}
"--------non-printable-characters------{{{1
"
" help: h listchars
set list
"set nolist
"set listchars=trail:.,extends:#,nbsp:.
set listchars=tab:\ \ ,extends:#,trail:⋅,nbsp:⋅
" show tabs more strongly for specific files
if has('autocmd')
autocmd filetype py set list
"␣␣
autocmd filetype py set listchars=tab:▷⋅,trail:.,extends:#,nbsp:.
endif
"1}}}
"--------WhitespaceWipers--------------{{{1
" delete all trailing whitespaces
" * carefull with MarkDown or any file which
" have meaningful trailing whitespaces
" * carefull with commits so as not to scramble diffs : do this
" only once in a while
function! s:enableWhitespaceWipers()
" in WHOLE FILE
map <silent> <S-F7> :%s/\s\+$//g<CR>
map <silent> <leader> <S-space> :%s/\s\+$//g<CR>
" on CURRENT LINE
nnoremap <silent> <leader><space> :s/\s\+$//g<CR>
vnoremap <silent> <leader><space> :s/\s\+$//g<CR>
endfunction
" remove mappings wich suppress whitespace
" (used later on for Markdown and Txt files)
function! s:removeWhitespaceWipers()
" in WHOLE FILE
silent! map <S-F7> :echo "disabled for markdown"<CR>
" on CURRENT LINE
"plhoste 2012-06-30 22:23:08 : disable that, it's useful, even in markdown
silent! nnoremap <leader><space> :echo "disabled for markdown"<CR>
silent! vnoremap <leader><space> :echo "disabled for markdown"<CR>
endfunction
function! s:markdownWhitespaceWipers()
" in WHOLE FILE: in the case of Markdown, 2 whitespaces at end of line
" mean : "force line break", so we only wipe out psaces if there are 3
" or more of them at EOL
map <silent> <S-F7> :%s/\s\s\s\+$//g<CR>
" on CURRENT LINE : no different than normal Whitespacewiper. On a
" single line, you can hardly make unrecoverable mistakes
nnoremap <silent> <leader><space> :s/\s\+$//g<CR>
vnoremap <silent> <leader><space> :s/\s\+$//g<CR>
endfunction
call s:enableWhitespaceWipers()
"1}}}
" --------Pase-in-insert-mode----------{{{1
" disable AUTOindenting when doing big pastes
set pastetoggle=<F10>
"1}}}
" --------PHP autoindent----------------{{{1
" autoindent PHP code (included in vim 703,
" otherwise, try this module :
" https://github.com/2072/PHP-Indenting-for-VIm
"
if v:version >= '703'
let g:PHP_autoformatcomment = 0
let g:PHP_default_indenting = 1
"let g:PHP_outdentphpescape = 0
endif
"1}}}
"--------JSON-autoindent-------------{{{1
" This will only work with the "yajl" package installed (MAcos brew, or linux)
" We first test for its existence
"
let __shellcmd = 'which json_reformat'
let __output=system(__shellcmd)
if !v:shell_error
autocmd BufNewFile,BufRead *.json set equalprg=json_reformat
endif
"}}}1
"--------XML-autoindent--------------{{{1
" This will only work with the "xml-fmt" tool from package "xml-coreutil"
" installed (MAcos brew, or linux)
" We first test for its existence
"
let __shellcmd = 'which xml-fmt'
let __output=system(__shellcmd)
if !v:shell_error
autocmd BufNewFile,BufRead *.xml set equalprg=xml-fmt
endif
"}}}1
" --------re-indent anyfile------------{{{1
" map <F8> to reindent file
noremap <F8> mzgg=G`z
inoremap <F8> <ESC>mzgg=G`z<Insert>
"1}}}
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" OTHER
"------------------------------------------------------------------------------
" --------Delete Empty Buffers------------{{{1
function! g:CleanEmptyBuffers()
let buffers = filter(range(0, bufnr('$')), 'buflisted(v:val) && empty(bufname(v:val)) && bufwinnr(v:val)<0')
if !empty(buffers)
exe 'bw '.join(buffers, ' ')
endif
endfunction
"1}}}
"##############################################################################
" COLORING
"##############################################################################
"
" GOTCHA : carefull to always declare User defined Colorscheme Groups such as
" those you would use in a statusline (named "User1" to "User9" and called by
" "set statusline+=%1*"), or others AFTER all the :colorscheme directives
" present in your .vimrc
"
"------------------------------------------------------------------------------
"
" ~~~~~~~~~~~~~~~~~~PRE~ColorScheming~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
" --------Custom Color Groups----------{{{1
" http://vim.wikia.com/wiki/Highlight_unwanted_spaces
" be aware that future colorscheme commands may clear all user-defined
" highlight groups. Using,the following autocmds, before the first colorscheme
" command will ensure that the highlight group gets created and is not cleared
" by future colorscheme commands. Other option is to use an "autocmd" on
" "ColorScheme" :help :colorscheme
" --------|__Trailing Whitespace-------{{{2
"MESSY: not optimal!!! (todo)
function! s:lightenTrailingWhitespace()
highlight ExtraWhitespace ctermbg=gray guibg=gray
:autocmd ColorScheme * highlight ExtraWhitespace ctermbg=gray guibg=gray
endfunction
if has("autocmd")
:autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red
" make it lighter for formats which DO USE trailing spaces
:autocmd BufRead,BufNewFile *.{md,markdown,mdown,mkd,mkdn,jade} call s:lightenTrailingWhitespace()
endif
highlight ExtraWhitespace ctermbg=red guibg=red
"2}}}
" --------|__Long Lines (>80)----------{{{2
" discrete marking of long lines (> 80)
" (http://stackoverflow.com/questions/235439/vim-80-column-layout-concerns#answer-235970)
" and make that compatible with colorschemes which have background (light,
" dark) setup
function! s:setupLongLines()
" dont highlight for CSV
if (&ft=='csv' || &ft=='csv')
highlight OverLength ctermbg=transparent ctermfg= guibg=
else
if &background == "light"
highlight OverLength ctermbg=red ctermfg=white guibg=#efe9d6
else
highlight OverLength ctermbg=red ctermfg=white guibg=#592929
endif
endif
endfunction
if has("autocmd")
autocmd ColorScheme * call s:setupLongLines()
endif
call s:setupLongLines()
" NB : warning : for some reason, put this AFTER the 'set list' command
" otherwise it won't work
" match OverLength /\%81v.\+/
"2}}}
" --------|__TABS----------------------{{{2
" discrete marking of TABS when they are not used ONLY for indenting
" and make that compatible with colorschemes which have background (light,
" dark) setup
function! s:setupInappropriateTabs()
if &background == "light"
highlight InappropriateTabs ctermbg=darkred ctermfg=white guibg=#e1d9bf
else
highlight InappropriateTabs ctermbg=darkred ctermfg=white guibg=#431616
endif
endfunction
if has("autocmd")
autocmd ColorScheme * call s:setupInappropriateTabs()
endif
call s:setupInappropriateTabs()
" NB : warning : for some reason, put this AFTER the 'set list' command
" otherwise it won't work
" match OverLength /\%81v.\+/
"2}}}
"1}}}
" --------Match, 2match, 3match--------{{{1
" Any ":match highlighting" applies only to the "current window". With the
" following in your vimrc, the command will be applied to the first window,
" and to any subsequent windows. The pattern * applies the highlight to all
" files.
" NB "only 3 matches" can be used (match, 2match, 3match)
"
" --------|__Trailing Whitespace-------{{{2
"" Show leading whitespace that includes spaces, and trailing whitespace.
"autocmd BufWinEnter * match ExtraWhitespace /^\s* \s*\|\s\+$/
" highlight trailing whitespaces so they are easier to spot
if has("autocmd")
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
endif
match ExtraWhitespace /\s\+\%#\@<!$/
match ExtraWhitespace /\s\+$/
match ExtraWhitespace /\s\+$/
"2}}}
" --------|__Long Lines (>80)----------{{{2
if has("autocmd")
" dont highlight for CSV
if (&ft=='csv' || &ft=='csv')
autocmd BufwinEnter * 2match OverLength /\%81v.\+/
endif
endif
if (&ft=='csv' || &ft=='csv')
2match OverLength /\%81v.\+/
endif
"2}}}
" --------|__TAB Detection-------------{{{2
"
" mark non-indent tabs, except on commented lines where we can do WTF we want
if has("autocmd")
autocmd BufwinEnter * 3match InappropriateTabs /[^"\t]\zs\t\+/
autocmd BufwinEnter *.txt 3match none
endif
3match InappropriateTabs /[^"\t]\zs\t\+/
"2}}}
"1}}}
" --------ClearMatches on BufWinLeave--{{{1
"
"
" It seems that vim does not handle sucessive calls of the match command
" gracefully. Since BufWinEnter commands are executed every time a buffer is
" displayed (i.e., switching to another file), the match command is executed
" many times during a vim session. This seems to lead to a memory leak which
" slowly impacts performance (for example scrolling and writing become
" unbearable slow). Include the following line to fix the issue:
autocmd BufWinLeave * call clearmatches()
"1}}}
" --------Color Scheme-------------------{{{1
" in GUI or 256-color terminal, default theme Lucius
if has("gui_running") || &t_Co >= 16
silent! set background=light
let g:lucius_style='light'
let g:lucius_contrast_bg='normal'
colorscheme lucius
call togglebg#map("<F5>") " F5 toggle background
" Terminal, old Vim => dante, which works everywhere
elseif v:version < '703'
colorscheme dante
" GNU Screen
elseif $STY != ""
colorscheme moria
" BASIC TERM or LINUX CONSOLE (TTY)
else
if (&term == "xterm") || (&term == "linux")
set t_Co=16
elseif &term == "vt320"
set t_Co=8
endif
"colorscheme mustang
"colorscheme dante
"colorscheme noctu
"silent! set background=dark
"set background=dark
colorscheme smyck
endif
"DARK
nnoremap <silent> <leader>$& :silent! colorscheme solarized <bar>set background=dark <CR> <CR> " $ 1
nnoremap <silent> <leader>$é :silent! colorscheme mustang <bar>set background=dark <CR> <CR> " $ 2
nnoremap <silent> <leader>$" :silent! colorscheme vibrantink2 <bar>set background=dark <CR> <CR> " $ 3
nnoremap <silent> <leader>$' :silent! colorscheme jellybeans <bar>set background=dark <CR> <CR> " $ 4