forked from alrra/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
940 lines (588 loc) · 24.6 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
" ----------------------------------------------------------------------
" | General Settings |
" ----------------------------------------------------------------------
" Don't make Vim vi-compatibile.
set nocompatible
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Enable syntax highlighting.
syntax on
if has('autocmd')
filetype plugin indent on
" │ │ └─ Enable file type detection.
" │ └────── Enable loading of indent file.
" └──────────── Enable loading of plugin files.
endif
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Copy indent to the new line.
set autoindent
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Allow backspace in insert mode.
set backspace=indent
set backspace+=eol
set backspace+=start
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Set directory for backup files.
set backupdir=~/.vim/backups
if has('wildignore')
" Don't create backups for certain files.
set backupskip='/tmp/*'
set backupskip+='/private/tmp/*'
endif
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Use the system clipboard as the default register.
set clipboard=unnamed
if has('unnamedplus')
set clipboard+=unnamedplus
endif
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" When making a change don't redisplay the line and
" instead put a `$` sign at the end of the changed text.
set cpoptions+=$
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if has('syntax')
" Highlight certain column(s).
set colorcolumn=73
" Highlight the current line.
set cursorline
endif
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Set directory for swap files.
set directory=~/.vim/swaps
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Use UTF-8 without BOM.
set encoding=utf-8 nobomb
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Increase command line history.
if has('cmdline_hist')
set history=5000
endif
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Search settings.
if has('extra_search')
" Enable search highlighting.
set hlsearch
" Highlight search pattern as it is being typed.
set incsearch
endif
" Ignore case in search patterns.
set ignorecase
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Always show the status line.
set laststatus=2
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Do not redraw the screen while executing macros,
" registers, and other commands that have not been typed.
set lazyredraw
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Use custom symbols to represent invisible characters.
set listchars=tab:▸\
set listchars+=trail:·
set listchars+=eol:↴
set listchars+=nbsp:_
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Enable extended regexp.
set magic
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Enable use of mouse clicks
set mouse=a
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Hide mouse pointer while typing.
set mousehide
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Disable error bells.
set noerrorbells
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" When using the join command only insert a single
" space after a `.`, `?`, or `!`.
set nojoinspaces
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Disable for security reasons.
" https://github.com/numirias/security/blob/cf4f74e0c6c6e4bbd6b59823aa1b85fa913e26eb/doc/2019-06-04_ace-vim-neovim.md#readme
set nomodeline
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Kept the cursor on the same column.
set nostartofline
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Show line number.
set number
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Increase the minimal number of columns used for the `line number`.
if has('linebreak')
set numberwidth=5
endif
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Report the number of lines changed.
set report=0
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Show cursor position.
if has('cmdline_info')
set ruler
endif
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" When scrolling keep the cursor 5 lines below
" the top and 5 lines above the bottom of the screen.
set scrolloff=5
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Avoid all the hit-enter prompts.
set shortmess=aAItW
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Show the command being typed.
if has('cmdline_info')
set showcmd
endif
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Show current mode.
set showmode
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Set the spellchecking language.
if has('syntax')
set spelllang=en_us
endif
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Override `ignorecase` option if the search pattern
" contains uppercase characters.
set smartcase
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Limit syntax highlighting.
" This avoids the very slow redrawing when files contain long lines.
if has('syntax')
set synmaxcol=2500
endif
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Set global <tab> settings.
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Enable fast terminal connection.
set ttyfast
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if has('persistent_undo')
" Set directory for undo files.
set undodir=~/.vim/undos
" Automatically save undo history.
set undofile
endif
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Allow cursor to be anywhere.
if has('virtualedit')
set virtualedit=all
endif
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Disable beeping and window flashing.
" https://vim.wikia.com/wiki/Disable_beeping
set visualbell
set noerrorbells
set t_vb=
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Enable enhanced command-line completion.
"
" By hitting <tab> in command mode, Vim will show the possible
" matches just above the command line with the first match being
" highlighted.
if has('wildmenu')
set wildmenu
endif
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Allow windows to be squashed.
if has('windows')
set winminheight=0
endif
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Prevent `Q` in `normal` mode from entering `Ex` mode.
nmap Q <Nop>
" ----------------------------------------------------------------------
" | Plugins |
" ----------------------------------------------------------------------
" Use `minpac` to manage the Vim plugins.
" https://github.com/k-takata/minpac
function! InitPlugins() abort
packadd minpac
call minpac#init()
call minpac#add('k-takata/minpac', { 'type': 'opt' })
call minpac#add('altercation/vim-colors-solarized')
call minpac#add('ap/vim-css-color')
call minpac#add('chrisbra/unicode.vim')
call minpac#add('chrisbra/vim-xml-runtime')
call minpac#add('editorconfig/editorconfig-vim')
call minpac#add('godlygeek/tabular')
call minpac#add('isRuslan/vim-es6')
call minpac#add('jelera/vim-javascript-syntax')
call minpac#add('ctrlpvim/ctrlp.vim')
call minpac#add('marijnh/tern_for_vim', { 'do': ':silent ! cd $HOME/.vim/pack/minpac/start/tern_for_vim && npm i &> /dev/null' })
call minpac#add('mattn/emmet-vim')
call minpac#add('mattn/webapi-vim', { 'type': 'opt' })
call minpac#add('mhinz/vim-signify')
call minpac#add('moll/vim-node')
call minpac#add('mtscout6/syntastic-local-eslint.vim')
call minpac#add('nathanaelkane/vim-indent-guides')
call minpac#add('raimondi/delimitmate')
call minpac#add('scrooloose/nerdtree')
call minpac#add('scrooloose/syntastic')
call minpac#add('sheerun/vim-polyglot', { 'type': 'opt' })
call minpac#add('shougo/neocomplcache.vim')
call minpac#add('shougo/neosnippet')
call minpac#add('shougo/neosnippet-snippets')
call minpac#add('thiagoalessio/rainbow_levels.vim')
call minpac#add('tomtom/tcomment_vim')
call minpac#add('tpope/vim-commentary')
call minpac#add('tpope/vim-fugitive')
call minpac#add('tpope/vim-repeat')
call minpac#add('tpope/vim-surround')
call minpac#add('tpope/vim-unimpaired')
call minpac#add('wellle/targets.vim')
endfunction
silent! packadd webapi-vim
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Define custom commands for managing plugins.
command! PluginsClean call InitPlugins() | call minpac#clean()
command! PluginsSetup call InitPlugins() | call minpac#update('', { 'do': 'qall' })
command! PluginsStatus call InitPlugins() | call minpac#status()
command! PluginsUpdate call InitPlugins() | call minpac#update('', { 'do': 'call minpac#status() | qall' })
" ----------------------------------------------------------------------
" | Plugins - Emmet |
" ----------------------------------------------------------------------
" Redefine trigger key.
let g:user_emmet_leader_key=","
" Only enable normal mode functions.
let g:user_emmet_mode='a'
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Load custom snippets.
if &runtimepath =~ 'webapi-vim'
let g:user_emmet_settings = webapi#json#decode(join(readfile(expand("~/.vim/snippets/emmet.json")), "\n"))
endif
" ----------------------------------------------------------------------
" | Plugins - Indent Guides |
" ----------------------------------------------------------------------
" Set custom indent colors.
" https://github.com/nathanaelkane/vim-indent-guides#setting-custom-indent-colors
let g:indent_guides_auto_colors = 0
autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd
\ guibg=#00323D
\ ctermbg=Magenta
autocmd VimEnter,Colorscheme * :hi IndentGuidesEven
\ guibg=#073642
\ ctermbg=DarkMagenta
" ----------------------------------------------------------------------
" | Plugins - Markdown |
" ----------------------------------------------------------------------
" Disable Folding.
" https://github.com/plasticboy/vim-markdown#disable-folding
let g:vim_markdown_folding_disabled=1
" ----------------------------------------------------------------------
" | Plugins - NeoComplCache |
" ----------------------------------------------------------------------
" Enable `neocomplcache` by default.
" https://github.com/Shougo/neocomplcache.vim#installation
let g:neocomplcache_enable_at_startup=1
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Make `Tab` autocomplete.
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Make `Shift+Tab` insert `Tab` character.
inoremap <S-TAB> <C-V><TAB>
" ----------------------------------------------------------------------
" | Plugins - Signify |
" ----------------------------------------------------------------------
" Disable Signify by default.
" https://github.com/mhinz/vim-signify
let g:signify_disable_by_default=1
" ----------------------------------------------------------------------
" | Plugins - Syntastic |
" ----------------------------------------------------------------------
" Inform Syntastic which checkers to use based on file types.
" https://github.com/scrooloose/syntastic#faq
let g:syntastic_javascript_checkers = [ 'eslint' ]
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Disable syntax checking by default.
let g:syntastic_mode_map = {
\ "active_filetypes": [],
\ "mode": "passive",
\ "passive_filetypes": []
\}
" ----------------------------------------------------------------------
" | Helper Functions |
" ----------------------------------------------------------------------
function! GetGitBranchName()
let branchName = ""
if exists("g:loaded_fugitive")
let branchName = "[" . fugitive#Head() . "]"
endif
return branchName
endfunction
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function! PrettyPrint()
if ( &filetype == 'json' && (has('python3') || has('python')) )
%!python -m json.tool
norm! ggVG==
elseif ( &filetype == 'svg' || &filetype == 'xml' )
set formatexpr=xmlformat#Format()
norm! Vgq
endif
endfunction
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function! StripBOM()
if has('multi_byte')
set nobomb
endif
endfunction
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function! StripTrailingWhitespaces()
" Save last search and cursor position.
let searchHistory = @/
let cursorLine = line(".")
let cursorColumn = col(".")
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Strip trailing whitespaces.
%s/\s\+$//e
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Restore previous search history and cursor position.
let @/ = searchHistory
call cursor(cursorLine, cursorColumn)
endfunction
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function! ToggleLimits()
" [51,73]
"
" * Git commit message
" http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
"
" [81]
"
" * general use
" https://daniel.haxx.se/blog/2020/11/30/i-am-an-80-column-purist/
if ( &colorcolumn == "73" )
set colorcolumn+=51,81
else
set colorcolumn-=51,81
endif
endfunction
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function! ToggleRelativeLineNumbers()
if ( &relativenumber == 1 )
set number norelativenumber
else
set number relativenumber
endif
endfunction
" ----------------------------------------------------------------------
" | Automatic Commands |
" ----------------------------------------------------------------------
if has("autocmd")
" Autocommand Groups.
" http://learnvimscriptthehardway.stevelosh.com/chapters/14.html
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Automatically reload the configurations from
" the `~/.vimrc` file whenever they are changed.
augroup auto_reload_vim_configs
autocmd!
autocmd BufWritePost vimrc source $MYVIMRC
augroup END
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Correctly recognize files.
augroup correctly_recognize_files
autocmd!
autocmd BufEnter gitconfig :setlocal filetype=gitconfig
autocmd BufEnter .gitconfig.local :setlocal filetype=gitconfig
augroup END
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Use relative line numbers.
" http://jeffkreeftmeijer.com/2012/relative-line-numbers-in-vim-for-super-fast-movement/
augroup relative_line_numbers
autocmd!
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Automatically switch to absolute
" line numbers when Vim loses focus.
autocmd FocusLost * :set number
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Automatically switch to relative
" line numbers when Vim gains focus.
autocmd FocusGained * :set relativenumber
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Automatically switch to absolute
" line numbers when Vim is in insert mode.
autocmd InsertEnter * :set number
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Automatically switch to relative
" line numbers when Vim is in normal mode.
autocmd InsertLeave * :set relativenumber
augroup END
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Automatically strip whitespaces when files are saved.
augroup strip_whitespaces
" List of file types for which the whitespaces
" should not be removed:
let excludedFileTypes = []
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Only strip the whitespaces if the file type is not
" in the excluded list.
autocmd!
autocmd BufWritePre * if index(excludedFileTypes, &ft) < 0 |
\ :call StripBOM() |
\ :call StripTrailingWhitespaces()
augroup END
endif
" ----------------------------------------------------------------------
" | Color Scheme |
" ----------------------------------------------------------------------
" Enable full-color support.
set t_Co=256
" Use colors that look good on a dark background.
set background=dark
" Set custom configurations for when the
" Solarized theme is used from Vim's Terminal mode.
"
" https://github.com/altercation/vim-colors-solarized
if !has("gui_running")
let g:solarized_contrast = "high"
let g:solarized_termcolors = 256
let g:solarized_termtrans = 1
let g:solarized_visibility = "high"
endif
silent! colorscheme solarized " Use custom color scheme.
" ----------------------------------------------------------------------
" | Key Mappings (overrides) |
" ----------------------------------------------------------------------
" Re-center view after:
" - half-page up
" - half-page down
" - Search - Next search pattern match
" - Search - Previous match
" Refs:
" - https://youtu.be/KfENDDEpCsI?si=2CVMBUAZQsKVX3b1&t=183
" - https://youtu.be/KfENDDEpCsI?si=hkn8WfiuHXMYGMyI&t=320
nnoremap <C-u> <C-u>zz
nnoremap <C-d> <C-d>zz
nnoremap n nzzzv
nnoremap N Nzzzv
" ----------------------------------------------------------------------
" | Key Mappings (custom) |
" ----------------------------------------------------------------------
" Use a different mapleader (default is "\").
let mapleader = " "
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" [,* ] Search and replace the word under the cursor.
nmap <leader>* :%s/\<<c-r><c-w>\>//<left>
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" [,cc ] Toggle code comments.
" https://github.com/tomtom/tcomment_vim
map <leader>cc :TComment<cr>
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" [,cr ] Calculate result.
" http://vimcasts.org/e/56
nmap <leader>cr 0yt=A<C-r>=<C-r>"<cr><esc>
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" [,cs ] Clear search.
map <leader>cs <esc>:noh<cr>
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" [,gd ] Toggle Git differences.
map <leader>gd :SignifyToggle<cr>
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" [,ffu] Convert file to use Unix line endings.
" See also: https://vim.fandom.com/wiki/File_format
map <leader>ffu :edit ++fileformat=dos <bar> :setlocal fileformat=unix <bar> :write!<cr><cr>
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" [,h ] Show hex dump.
nmap <leader>h :%!xxd<cr>
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" [,l ] Toggle `set list`.
nmap <leader>l :set list!<cr>
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" [,n ] Toggle `set relativenumber`.
nmap <leader>n :call ToggleRelativeLineNumbers()<cr>
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" [,pp ] Pretty print
map <leader>pp :call PrettyPrint()<cr>
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" [,rl ] Toggle `RainbowLevels`.
map <leader>rl :RainbowLevelsToggle<cr>
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" [,sb ] Strip BOM (Byte Order Mark).
nmap <leader>sb :call StripBOM()<cr>
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" [,sw ] Strip trailing whitespace.
nmap <leader>sw :call StripTrailingWhitespaces()<cr>
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" [,t ] Toggle NERDTree.
map <leader>t :NERDTreeToggle<cr>
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" [,ti ] Toggle indent.
nmap <leader>ti <plug>IndentGuidesToggle
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" [,tl ] Toggle show limits.
nmap <leader>tl :call ToggleLimits()<cr>
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" [,ts ] Toggle Syntastic.
nmap <leader>ts :SyntasticToggleMode \| w<cr>
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" [,v ] Make the opening of the `.vimrc` file easier.
nmap <leader>v :vsp $MYVIMRC<cr>
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" [,W ] Sudo write.
map <leader>W :w !sudo tee %<cr>
" ----------------------------------------------------------------------
" | Status Line |
" ----------------------------------------------------------------------
" Terminal types:
"
" 1) term (normal terminals, e.g.: vt100, xterm)
" 2) cterm (color terminals, e.g.: MS-DOS console, color-xterm)
" 3) gui (GUIs)
highlight ColorColumn
\ term=NONE
\ cterm=NONE ctermbg=237 ctermfg=NONE
\ gui=NONE guibg=#073642 guifg=NONE
highlight CursorLine
\ term=NONE
\ cterm=NONE ctermbg=235 ctermfg=NONE
\ gui=NONE guibg=#073642 guifg=NONE
highlight CursorLineNr
\ term=bold
\ cterm=bold ctermbg=NONE ctermfg=178
\ gui=bold guibg=#073642 guifg=Orange
highlight LineNr
\ term=NONE
\ cterm=NONE ctermfg=241 ctermbg=NONE
\ gui=NONE guifg=#839497 guibg=#073642
highlight User1
\ term=NONE
\ cterm=NONE ctermbg=237 ctermfg=Grey
\ gui=NONE guibg=#073642 guifg=#839496
" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
set statusline=
set statusline+=%1* " User1 highlight
set statusline+=\ [%n] " Buffer number
set statusline+=\ %{GetGitBranchName()} " Git branch name
set statusline+=\ [%f] " File path
set statusline+=%m " Modified flag
set statusline+=%r " Readonly flag
set statusline+=%h " Help file flag
set statusline+=%w " Preview window flag
set statusline+=%y " File type
set statusline+=[
set statusline+=%{&ff} " File format
set statusline+=:
set statusline+=%{strlen(&fenc)?&fenc:'none'} " File encoding
set statusline+=]
set statusline+=%= " Left/Right separator
set statusline+=%c " File encoding
set statusline+=,
set statusline+=%l " Current line number
set statusline+=/
set statusline+=%L " Total number of lines
set statusline+=\ (%P)\ " Percent through file
" Example result:
"
" [1] [main] [vim/vimrc][vim][unix:utf-8] 17,238/381 (59%)
" ----------------------------------------------------------------------
" | Local Settings |
" ----------------------------------------------------------------------
" Load local settings if they exist.
"
" [!] The following needs to remain at the end of this file in
" order to allow any of the above settings to be overwritten
" by the local ones.
if filereadable(glob("~/.vimrc.local"))
source ~/.vimrc.local
endif