-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc.reduced
1586 lines (1338 loc) · 38.8 KB
/
.vimrc.reduced
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
""""""
"" set improvement feature vIM
""
"""""
set nocompatible
""""""
"" set line number
""
"""""
set number
""""""
"" show number line and character count
"" for more info Ctrl-g - it has been overwritten
""
"""""
set ruler
""""""
"" show filename in status bar
"" to get full path `set statusline+=%F`
""
""""""
set laststatus=2
""""""
"" set relative line number from the cursor
""
"""""
set relativenumber
""""""
"" set split below as preferred than above
""
"""""
set splitbelow
""""""
"" set split right as preferred than left
""
"""""
set splitright
""""""
"" do not resize windows after opening and closing
""
"""""
set noea
""""""
"" case insensitive search
""
"""""
set ignorecase
""""""
"" case sensitive only of there is a Capital letter
""
"""""
set smartcase
""""""
"" set paste nopaste toggle with F3. If in paste mode, autoindetation is off.
"" usefull when pasting from clipboard.
""
"""""
set pastetoggle=<F3>
""""""
"" Change leader key
""
"""""
nnoremap <Space> <Nop>
noremap <Space> <Nop>
sunmap <Space>
let mapleader = " "
""""""
"" If set to high value like 999 the cursor will be always in the middle of
"" the window.
"" The value is how many rows must be always before and after the cursor.
""
"""""
"" set scrolloff=999
""""""
"" enabling syntax highlight
""
"""""
syntax enable
"""""
"" syntax highlight breaks on large files.
"" This should fix it, however it might slow down Vim
"" issue: https://github.com/vim/vim/issues/2790
"" https://stackoverflow.com/questions/27235102/vim-randomly-breaks-syntax-highlighting
""
"""""
""set re=1
""set redrawtime=10000
""syntax sync fromstart
autocmd BufEnter * syntax sync fromstart
""""""
"" set relative number in Normal mode
"" set absolute number in Insert mode
""
"""""
augroup numbertoggle
autocmd!
autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
augroup END
""""""
"" add to autocomplete spelling
""
"""""
set complete+=kspell
""""""
"" add spell checking
""
"""""
""set spell
""""""
"" force indentation of two with one tab only
""
"""""
set autoindent
set noexpandtab
set smartindent
set smarttab
set tabstop=2
set shiftwidth=2
""""""
"" set tabs for markdown file type
""
"""""
"" autocmd FileType md setlocal shiftwidth=2 tabstop=2
""""""
"" indent after opening curly braces
""
"""""
inoremap {}<Left><CR> {<CR>}<C-o>O
""""""
"" to not remove the indentation when pressing Esc
""
"""""
"inoremap <esc> ~<bs><esc>
""""""
"" to not remove the indentation when pressing Enter
""
"""""
inoremap <cr> ~<bs><cr>
""""""
"" set show command to true
""
"""""
"set showcmd
""""""
"" set visual alert
""
"""""
set visualbell
""""""
"" set update time
""
"""""
set updatetime=200
""""""
"" set folding method to indent
"" possible: manual, indent, syntax, expr, marker, diff
"" I was using syntax, then indent
""
"""""
set foldmethod=indent
""""""
"" set the level of open fold when opening a buffer
"" if set to 0 all the file will be opened with folded code
""
"""""
set foldlevelstart=20
""""""
"" save every time you leave insert mode
""
"""""
""autocmd InsertLeave * write
""""""
"" save a backupfile before overwriting one
"" Use this if you don't want to use 'set backup' and 'backupdir'
""
"""""
""set writebackup
""""""
"" set backup
""
"""""
set backup
""""""
"" set backupdir
""
"""""
set backupdir=~/.vim/.vim_backups/
""""""
"" yes will make a copy of the file as backup
"" Set to yes so that webpack can better watch file changing
""
""""""
set backupcopy=yes
""""""
"" set patchmode, save a backupfile and append it .orig to its name
""
"""""
""set patchmode=.orig
""""""
"" Before writing append to its name date and time
"" &bex is backup extension
""
"""""
autocmd BufWritePre * let &bex = '-' . strftime("%Y-%m-%d-%H-%M")
"" autocmd BufWritePre * let &bex = '-' . strftime("%Y-%m-%d-%H-%M") . '-' . expand('%')
""""""
"" Typescript support for importing esmodule with .js extension
"" This allow to use `gf` to go to file with extension '.ts' instead of '.js'
""
"""""
set includeexpr=substitute(v:fname,'\\.js','.ts','g')
""""""
"" Search down in subfolders of the root
""
"""""
set path+=**
""""""
"" Display all matching files when tab complete
""
"""""
set wildmenu
""""""
"" set no terminal gui colors
""
"""""
set notermguicolors
""""""
"" set colorscheme
"" edge must be set with notermguicolors
""
"""""
colorscheme edge
""""""
"" set colorscheme according to filetype
""
"""""
"" autocmd BufEnter * colorscheme edge
"" autocmd BufEnter *.html colorscheme monokai
"" au BufReadPost *.vue set syntax=html
""""""
"" set Vim-specific sequences for RGB colors
""
"""""
""let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
""let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
""""""
"" set custom characters
""
"""""
""""""
"" in combination with 'set listchars' will make all other character invisible
"" like a space
""
"""""
"set list
""""""
"" overwrite colorscheme highlight colors
""
""" Non-textual charcater color
""" Special character color
""" Matching character color
""" htmlTag and htmlEndTag
""
"""""
"autocmd ColorScheme *
" \ highlight NonText ctermfg=236 guifg=#343434 ctermbg=NONE |
" \ highlight SpecialKey ctermfg=241 guifg=#626262 |
" \ highlight cssTagName ctermfg=111 guifg=#87afff |
" \ highlight sassClass ctermfg=117 guifg=#87d7ff |
" \ highlight cssClassName ctermfg=75 guifg=#5fafff |
" \ highlight cssClassNameDot ctermfg=75 guifg=#5fafff |
" \ highlight storageClass ctermfg=141 guifg=#af87ff |
" \ highlight jsObjectKey ctermfg=147 guifg=#afafff |
" \ highlight jsFunction ctermfg=141 guifg=#af87ff |
" "\ highlight Keyword ctermfg=110 guifg=#87afd7 |
" \ highlight typescriptObjectLabel ctermfg=110 guifg=#87afd7 |
" \ highlight typescriptFuncKeyword ctermfg=141 guifg=#af87ff |
" \ highlight typescriptExport ctermfg=203 guifg=#ff5f5f |
" "\ highlight typescriptInterfaceKeyword ctermfg=203 guifg=#ff5f5f |
" \ highlight typescriptInterfaceExtends ctermfg=203 guifg=#ff5f5f |
" \ highlight typescriptObjectStaticMethod ctermfg=147 guifg=#afafff |
" \ highlight typescriptDOMFormProp ctermfg=147 guifg=#afafff |
" \ highlight typescriptConstructSignature ctermfg=202 guifg=#ff5f5f |
" \ highlight typescriptVariableDeclaration ctermfg=250 guifg=#bcbcbc |
" \ highlight typescriptVariable ctermfg=176 guifg=#d787d7 |
" \ highlight typescriptKeywordOp ctermfg=176 guifg=#d787d7 |
" \ highlight typescriptHeadersMethod ctermfg=110 guifg=#87afd7 |
" \ highlight typescriptResponseProp ctermfg=110 guifg=#87afd7 |
" \ highlight typescriptReflectMethod ctermfg=110 guifg=#87afd7 |
" \ highlight typescriptPromiseMethod ctermfg=110 guifg=#87afd7 |
" \ highlight typescriptClassKeyword ctermfg=202 guifg=#ff5f5f |
" \ highlight typescriptClassExtends ctermfg=202 guifg=#ff5f5f |
" \ highlight typescriptAliasKeyword ctermfg=141 guifg=#af87ff |
" \ highlight typescriptFileReaderProp ctermfg=250 guifg=#bcbcbc |
" \ highlight typescriptProp ctermfg=110 guifg=#87afd7 |
" \ highlight typescriptConstructorType ctermfg=202 guifg=#ff5f5f |
" \ highlight link sassClassChar sassClass |
" \ highlight link htmlTag htmlTagName |
" \ highlight link htmlEndTag htmlTagName |
" "\ highlight MatchParen ctermfg=195 |
" "" Chracter color after 80th char
" "\ highlight Terminal ctermbg=240 ctermfg=230 guibg=#232323 guifg=#DDDDDD |
" "\ highlight OverLength ctermbg=red ctermfg=white guibg=#592929 |
" "\ match OverLength /\%81v.\+/
""""""
"" column colored with hl-ColorColumn command
"" Only 80 to sign where it is
""
"""""
set colorcolumn=80
""""""
"" Custom cursor color
""
"" :set is for setting options
"" :let is for assigning value to variables
""
"" This are equivalent tho, since &tw refer to the option tw
"" :set tw=40
"" :let &tw=40
""
"" Cursor colors in different terminals
"" https://vim.fandom.com/wiki/Change_cursor_shape_in_different_modes
""
"" The if will check if the terminal supper the escape command to change color
""
"""""
" if &term =~ "xterm\\|rxvt"
" " use an red cursor in insert mode
" let &t_SI = "\<Esc>]12;#882222\x7"
" " use a blue cursor otherwise
" let &t_EI = "\<Esc>]12;#2266FF\x7"
" silent !echo -ne "\033]12;grey\007"
" " reset cursor when vim exits
" autocmd VimLeave * silent !echo -ne "\033]112\007"
" " use \003]12;gray\007 for gnome-terminal and rxvt up to version 9.21
" endif
"" Changing cursor shape per mode
"" 1 or 0 -> blinking block
"" 2 -> solid block
"" 3 -> blinking underscore
"" 4 -> solid underscore
""if exists('$TMUX')
"" " tmux will only forward escape sequences to the terminal if surrounded by a DCS sequence
"" let &t_SI .= "\<Esc>Ptmux;\<Esc>\<Esc>[1 q\<Esc>\\"
"" let &t_EI .= "\<Esc>Ptmux;\<Esc>\<Esc>[2 q\<Esc>\\"
"" autocmd VimLeave * silent !echo -ne "\033Ptmux;\033\033[0 q\033\\"
""else
let &t_SI .= "\<Esc>[1 q"
let &t_EI .= "\<Esc>[2 q"
autocmd VimLeave * silent !echo -ne "\033[0 q"
""endif
""""""
"" Cursor color for Tmux
"" Blue on normal mode
"" Red on insert mode
""
"""""""
"if exists('$TMUX')
" let &t_EI = "\<Esc>Ptmux;\<Esc>\033]12;#2266FF\007\<Esc>\\"
" let &t_SI = "\<Esc>Ptmux;\<Esc>\033]12;#882222\007\<Esc>\\"
" "silent !echo -ne "\<Esc>Ptmux;\<Esc>\033]Pl3971ED\033\\"
" "silent !echo -ne "\<Esc>Ptmux;\<Esc>\033]Pl3971ED\033\\"
" "autocmd VimLeave * silent !echo -ne "\<Esc>Ptmux;\<Esc>\033]Pl3971ED\033\\"
" autocmd VimLeave * silent !echo -ne "\033]12;grey27\007"
"else
" let &t_EI = "\033]12;#2266FF\033\\"
" let &t_SI = "\033]12;#882222\033\\"
" silent !echo -ne "\033]12;grey27\033\\"
" autocmd VimLeave * silent !echo -ne "\033]12;grey27\033\\"
"endif
""""""
"" Highlight CSS VendorPrefix
""
"""""
"autocmd BufWritePre,BufRead *.css
" \ highlight VendorPrefix ctermfg=red term=italic |
" \ match VendorPrefix /-\(moz\|webkit\|o\|ms\)-[a-zA-Z-]\+/
"autocmd BufWritePre,BufRead *.scss
" \ highlight VendorPrefix ctermfg=red term=italic |
" \ match VendorPrefix /-\(moz\|webkit\|o\|ms\)-[a-zA-Z-]\+/
"autocmd BufWritePre,BufRead *.sass
" \ highlight VendorPrefix ctermfg=red term=italic |
" \ match VendorPrefix /-\(moz\|webkit\|o\|ms\)-[a-zA-Z-]\+/
""""""
"" Not sure what is does
"" It seems \G remove highlight
""
"""""
""nnoremap <Leader>G G?\S<CR>:noh<CR>
""""""
"" Set command for custom function loaded from a file
""
"""""
""source ~/vcomments.vim
""map <C-a> :call Comment()<CR>
""map <C-b> :call Uncomment()<CR>
""""""
"" Function and command for toggoling AutoRead
"" Autoread will update the buffer if the file is changed outside Vim
""
"""""
function! ToggleAutoRead()
set ar!
au CursorHold * checktime
endfunction
command! AutoRead :call ToggleAutoRead()
""""""
"" Define command MakeTags for generating ctags
""
"" For typescript support https://github.com/jb55/typescript-ctags
""
"""""
""command! MakeTags !ctags -R .
command! MakeTags !ctags -R --exclude=.git --exclude=node_modules .
set tags=tags;/
""""""
"" Enable plugins
""
"""""
filetype plugin on
""""""
"" Set background dark for Tmux
""
""""""
set background=dark
""""""
"" After upgrading VIM to 8.2 this will fix strange character
"" that were randomly appearing >4;2m
"" It is something related with the terminal command
""
""""""
let &t_TI = ""
let &t_TE = ""
""""""
"" This will make the delete key deleting characters
""
""""""
set backspace=indent,eol,start
""""""
"" enable swapfile
""
"""""
set swapfile
""""""
"" Polyglot variable that must be set before plugin.
""
""""""
"let g:polyglot_disabled = ['sensible']
""""""
"" Enable syntax highlight in markdown code blocks
""
""""""
"let g:markdown_fenced_languages = [
" \ 'bash=sh', 'javascript', 'js=javascript', 'json=javascript', 'typescript',
" \ 'ts=typescript', 'php', 'html', 'css', 'rust', 'sql']
""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""" COMMANDS """"""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""
command Vt vertical terminal
""""""
"" - The follwoing command :Sw allow to write in sudo when the file wasn't opened
"" with sudo privileges.
"" - The recommended way is to edit the file wiht `sudoedit` though.
"" `sudoedit` check the environmental variable $EDITOR, that should be set to
"" `vim`, make a copy in a tmp dir and save it as sudo when finished. [Safer]
"" - `sudoedit` is equivalent to `sudo -e`
"" - Another way is to run `sudo -E vim` -E flag or --preserve-env will keep
"" the environmental variables so that vim will run the user .vimrc [Not safe]
""
""""""
command! -nargs=0 Sw w !sudo tee % > /dev/null
""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""" PLUGINS """""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" Specify a directory for plugins
"" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.vim/plugged')
""""""
"" Autocomplete
""
""""""
"Plug 'neoclide/coc.nvim', {'branch': 'release'}
""""""
"" For autocomplete while typeing
""
""""""
"" Plug 'Valloric/YouCompleteMe'
""""""
"" Javascript syntax
""
""""""
"" Plug 'pangloss/vim-javascript'
""""""
"" A collection of language packs for Vim.
""
"" With this plugin Vue files are superslow.
""
"" -- Needed to be disable.
"" -- It is forcing PHP file to tab with 4 spaces.
""
""""""
""Plug 'sheerun/vim-polyglot'
""""""
"" A Vim plugin which shows a git diff in the sign column.
""
""""""
Plug 'airblade/vim-gitgutter'
""""""
"" Syntax file and other settings for TypeScript
""
""""""
"" "Plug 'leafgarland/typescript-vim'
""""""
"" TSServer
""
""""""
"" "Plug 'Quramy/tsuquyomi'
""""""
"" Typescript for Vue
""
""""""
"" "Plug 'Quramy/tsuquyomi-vue'
""""""
"" Syntax Highlighting for Vue
""
""""""
"" Plug 'posva/vim-vue'
""""""
"" JS and TS indent
""
""""""
"" "Plug 'jason0x43/vim-js-indent'
""""""
"" Plugin for comment shortcut
""
""""""
"" "Plug 'preservim/nerdcommenter'
""""""
"" Another plugin for comment
""
""""""
Plug 'tpope/vim-commentary'
""""""
"" Another plugin for comment
""
""""""
"" "Plug 'tomtom/tcomment_vim'
""""""
"" Plugin for linting
""
""""""
"" Plug 'dense-analysis/ale'
""""""
"" Plugin for linting
""
""""""
"" "Plug 'vim-syntastic/syntastic'
""""""
"" Highlight HTML matching tags
""
""""""
"" Plug 'Valloric/MatchTagAlways'
""""""
"" Install FZF in VIM - FuzzyFinder
"" After installing you need to
"" set rtp+=~/.fzf See below plugin section
""
""""""
""Plug 'junegunn/fzf.vim'
"Plug 'junegunn/fzf.vim', { 'do': { -> fzf#install() } }
"""""
"" A Fuzzy Finder plugin
"" https://github.com/ctrlpvim/ctrlp.vim
""
"""""
Plug 'ctrlpvim/ctrlp.vim'
"""""
"" a plugin which disables the arrow keys, the hjkl keys,
"" the page up/down keys, and a handful of other keys
""
"""""
"" "Plug 'wikitopian/hardmode'
"""""
"" surroundings: parentheses, brackets, quotes, XML tags, and more.
""
"""""
Plug 'tpope/vim-surround'
"""""
"" NERDTree
""
"""""
"" "Plug 'preservim/nerdtree'
"""""
"" Vim-prettier
""
"""""
"" Plug 'prettier/vim-prettier'
"""""
"" Vim-pug
""
"""""
"" Plug 'digitaltoad/vim-pug'
"""""
"" Vim-toml
""
"""""
Plug 'cespare/vim-toml'
"""""
"" Vim-plist
""
"""""
Plug 'darfink/vim-plist'
"""""
"" Vim-coffe-script syntax
""
"""""
"" Plug 'kchmck/vim-coffee-script'
"""""
"" Search with ack
""
"""""
"" Plug 'mileszs/ack.vim'
"""""
"" Debugger
""
"""""
"Plug 'puremourning/vimspector'
"""""
"" Debugger
""
"""""
"Plug 'nikvdp/ejs-syntax'
"""""
"" GraphQL syntax highlight
""
"""""
"Plug 'jparise/vim-graphql'
call plug#end()
"""""
"" Change ACK with AG The silver searcher
""
"""""
"" let g:ackprg = 'ag --vimgrep'
""""""
"" The plugin manager https://github.com/junegunn/vim-plug was forcing to use
"" Sass indentation with spaces instead of tabs. The following command will fix
"" it. Setting globally to not expand tabs
""
""""""
""set noexpandtab
""autocmd FileType sass setlocal noexpandtab
""autocmd FileType php setlocal noexpandtab
""""""
"" add indentation with tabs also to empty lines for PHP files
"" For some reason on PHP it wasn't working.
""
"""""
"autocmd FileType php setlocal autoindent
"autocmd FileType php inoremap <esc> ~<bs><esc>
"autocmd FileType php inoremap <cr> <space><bs><cr>
""""""
"" This will close the info windows when autocomplete has been selected
""
""""""
autocmd CompleteDone * pclose
""""""
"" Custom remappings after plugins
""
""""""
""""""
"" Remap scrolling
""
""""""
nnoremap J <C-e>
nnoremap K <C-y>
nnoremap <S-C-j> <C-d>
nnoremap <S-C-k> <C-u>
""""""
"" Remap hjkl in Insert mode
""
""""""
inoremap <C-h> <Left>
inoremap <C-j> <Down>
inoremap <C-k> <Up>
inoremap <C-l> <Right>
""""""
"" Remap _search next_ to _search next and center_ in the window
""
""""""
nnoremap n nzz
nnoremap N Nzz
nnoremap * *zz
nnoremap # #zz
nnoremap g* g*zz
nnoremap g# g#zz
nnoremap G Gzz
nnoremap <C-o> <C-o>zz
nnoremap <C-i> <C-i>zz
""""""
"" Command Remap search `/` and `?` (backward search)
"" with zz at the end for centering the cursor in the middle of the page
""
""""""
function! CenterSearch()
let cmdtype = getcmdtype()
if cmdtype == '/' || cmdtype == '?'
return "\<enter>zz"
endif
return "\<enter>"
endfunction
cnoremap <silent> <expr> <enter> CenterSearch()
""""""
"" Mapping for search and replace word under cursor
"" Ctrl-s
""
""""""
nnoremap <C-S> :%s/\<<C-r><C-w>\>/
""""""
"" Mapping for search and replace word under cursor
"" Globally with a single check on all occurrences
"" Leader(space)Ctrl-s
""
""""""
"" nnoremap <leader>gs :g/\<<C-r><C-w>\>/#|s/\<<C-r><C-w>\>/
""""""
"" Mapping for search and replace word under cursor in the last Visual
"" selection
"" Ctrl-A
""
""""""
nnoremap <C-A> :%s/\%V\<<C-r><C-w>\>/
""""""
"" Mapping for :grep
"" Ctrl-g
""
""""""
nnoremap <C-G> :tabe<CR>:grep -iR
""""""
"" Mapping for :tabclose
""
""""""
command! Tc :tabclose
""""""
"" Mapping missspelled
""
""""""
command WQ wq
command Wq wq
command W w
command Q q
""""""
"" Remap ctrl-n to :cn for going next entry to quicklist after :grep
"" Remap ctrl-m to :cp for going previous entry to quicklist after :grep
""
""""""
nmap <silent> <C-N> :cn<CR>zz
nmap <silent> <C-M> :cp<CR>zz
""""""
"" Press Space to turn on/off searched term highlighting and clear
"" any message already displayed.
""
"""""
nnoremap <silent> \ :set hlsearch!<Bar>:echo<CR>
""""""
"" Remap CTAGS command `go to defintion`
"" Lowercase 'gd' go to defintion by skipping prompt of selecting defintion
"" Uppercase 'gD' go to defintion in a splitted window
"" Both uppercase 'GD' show prompt
""
"" Overwritten by COC, check below
""
"""""
"" nnoremap gd g]1<CR><CR>zz
"" nnoremap gD :<c-u>rightbelow vertical stjump <c-r><c-w><cr>zz
""nnoremap GD g]
""""""
"" Autoclose (X)HTML tags
""
""""""
""inoremap > ></<C-x><C-o><C-y><C-o>%<CR><C-o>
""inoremap input> input>
""inoremap br> br>
""inoremap /> />
inoremap ><Tab> ><Esc>F<lyt>A</<C-r>"><Esc>F<i
""""""
"" Autocompleting HTML tags
""
""""""
"autocmd FileType html,php,vue set omnifunc=htmlcomplete#CompleteTags
""""""
"" Press F10 to
"" show highlight group name under the cursor
""
""""""
"map <F10> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<'
"\ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<"
"\ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>
""""""
"" Press F9 to
"" show highlight group color under the cursor
""
""""""
"map <F9> :echo "fg<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"fg") . '> bg<'
"\ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"bg") . ">"<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""" COC Autocomplete """"""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""
"" use <tab> for trigger completion and navigate to the next complete item
" function! s:check_back_space() abort
" let col = col('.') - 1
" return !col || getline('.')[col - 1] =~ '\s'
" endfunction
"" inoremap <silent><expr> <Tab>
"" \ pumvisible() ? "\<C-n>" :
"" \ <SID>check_back_space() ? "\<Tab>" :
"" \ coc#refresh()
"" Cursor disappeared after exit CocList
"" Possible bug with guicursor option on your terminal, you can disable
"" transparent cursor by
let g:coc_disable_transparent_cursor = 1
"" Use <Tab> and <S-Tab> to navigate the completion list
"" inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
"" inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
""" Enable and disable coc-extension according to filetype
"" augroup toggleCocExtensions
"" autocmd!
"" autocmd BufEnter *.ts call CocActionAsync('activeExtension', 'coc-tsserver')
"" autocmd BufEnter *.ts call CocActionAsync('deactivateExtension', 'coc-eslint')
"" " autocmd BufLeave *.ts call CocActionAsync('deactivateExtension', 'coc-tsserver')
"" " autocmd BufLeave *.ts call CocActionAsync('activeExtension', 'coc-eslint')
"" augroup END
"" GoTo code navigation.
"" nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gvd :call CocAction('jumpDefinition', 'tab drop')<CR>
nmap <silent> gd :call CocAction('jumpDefinition', 'drop')<CR>
nmap <silent> gy <Plug>(coc-type-definition)
"" nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
"" Use K to show documentation in preview window.
nnoremap <leader>t :call ShowDocumentation()<CR>
function! ShowDocumentation()
if CocAction('hasProvider', 'hover')
call CocActionAsync('doHover')
else
call feedkeys('K', 'in')
endif
endfunction
"" Highlight the symbol and its references when holding the cursor.
"" autocmd CursorHold * silent call CocActionAsync('highlight')
"" Run the Code Lens action on the current line.
nmap <leader>cl <Plug>(coc-codelens-action)
"" New remap keys from version 0.0.82
"inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm() : "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
"inoremap <silent><expr> <C-x><C-z> coc#pum#visible() ? coc#pum#stop() : "\<C-x>\<C-z>"
"
" remap for complete to use tab and <cr>
" inoremap <silent><expr> <TAB>
" \ coc#pum#visible() ? coc#pum#next(1):
" \ <SID>check_back_space() ? "\<Tab>" :
" \ coc#refresh()