-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.vimrc
4312 lines (3825 loc) · 131 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
scriptencoding utf-8
" Vim settings
"
" Maintainer: DeaR <[email protected]>
" Last Change: 31-Oct-2017.
" License: MIT License {{{
" Copyright (c) 2013 DeaR <[email protected]>
"
" Permission is hereby granted, free of charge, to any person obtaining a
" copy of this software and associated documentation files (the
" "Software"), to deal in the Software without restriction, including
" without limitation the rights to use, copy, modify, merge, publish,
" distribute, sublicense, and/or sell copies of the Software, and to permit
" persons to whom the Software is furnished to do so, subject to the
" following conditions:
"
" The above copyright notice and this permission notice shall be included
" in all copies or substantial portions of the Software.
"
" THE OSFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
" OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE OSFTWARE OR
" THE USE OR OTHER DEALINGS IN THE OSFTWARE.
" }}}
"==============================================================================
" Pre Init: {{{
" Skip vim-tiny, vim-small, below vim-7.4
if v:version < 704 | finish | endif
" Be iMproved
if &compatible
set nocompatible
endif
" Encoding
set encoding=utf-8
scriptencoding utf-8
if &term == 'win32'
set termencoding=cp932
endif
if has('win32')
" Language
language japanese
language time C
" Shell
" set shell=sh
" set shellslash
" Path
let $PATH = $VIM . ';' . $PATH
" Unix like path
let &runtimepath = substitute(&runtimepath,
\ '\V' . escape($HOME, '\') . '/\zsvimfiles', '.vim', 'g')
if has('packages')
let &packpath = substitute(&packpath,
\ '\V' . escape($HOME, '\') . '/\zsvimfiles', '.vim', 'g')
endif
endif
" XDG Base Directory
let $XDG_DATA_HOME =
\ exists('$XDG_DATA_HOME') ? $XDG_DATA_HOME : ($HOME . '/.local/share')
let $XDG_CACHE_HOME =
\ exists('$XDG_CACHE_HOME') ? $XDG_CACHE_HOME : ($HOME . '/.cache')
let $XDG_CONFIG_HOME =
\ exists('$XDG_CONFIG_HOME') ? $XDG_CONFIG_HOME : ($HOME . '/.config')
" Singleton
let s:singleton_dir =
\ $XDG_DATA_HOME . '/dein/repos/github.com/thinca/vim-singleton'
if has("clientserver") && isdirectory(s:singleton_dir)
execute 'set runtimepath^=' . escape(escape(s:singleton_dir, ' ,'), ' \')
let g:singleton#opener = 'drop'
call singleton#enable()
endif
unlet! s:singleton_dir
" Vimrc autocmd group
augroup MyVimrc
autocmd!
augroup END
"------------------------------------------------------------------------------
" Variable: {{{
" Ignore pattern
let s:ignore_dir = [
\ '.git', '.hg', '.bzr', '.svn']
let s:ignore_file = [
\ '*.exe', '*.bin', '*.axf',
\ '*.o', '*.obj', '*.a', '*.lib', '*.so', '*.dll', '*.dylib',
\ 'tags', 'tags-??', '*~', '*.swp', '*.swo', '*.swn', '*.lc',
\ '*.elc', '*.fas', '*.pyc', '*.pyd', '*.pyo', '*.luac', '*.zwc']
let s:ignore_ft = [
\ 'gitcommit', 'gitrebase', 'hgcommit']
if has('win32')
call extend(s:ignore_dir, [
\ 'AppData', 'TuruKameData'])
endif
"------------------------------------------------------------------------------
" Common: {{{
" Script ID
function! s:SID() abort
if !exists('s:_SID')
let s:_SID = matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze_SID$')
endif
return s:_SID
endfunction
" Cached executable
let s:_executable = {}
function! s:executable(expr) abort
if !has_key(s:_executable, a:expr)
let s:_executable[a:expr] = executable(a:expr)
endif
return s:_executable[a:expr]
endfunction
" CPU Cores
function! s:cpucores() abort
if !exists('s:_cpucores')
let s:_cpucores = str2nr(
\ exists('$NUMBER_OF_PROCESSORS') ? $NUMBER_OF_PROCESSORS :
\ s:executable('nproc') ? system('nproc') :
\ s:executable('getconf') ? system('getconf _NPROCESSORS_ONLN') :
\ s:executable('sysctl') ? system('sysctl hw.ncpu') :
\ filereadable('/proc/cpuinfo') ?
\ len(filter(readfile('/proc/cpuinfo'), 'v:val =~ "processor"')) : 1)
endif
return s:_cpucores
endfunction
" Check japanese
let s:is_lang_ja = v:lang =~? '^ja'
" Check colored UI
let s:is_colored_ui = has('gui_running') || has('termguicolors') || &t_Co > 255
" Check JIS X 0213
let s:has_jisx0213 = has('iconv') &&
\ iconv("\x87\x64\x87\x6a", 'cp932', 'euc-jisx0213') ==# "\xad\xc5\xad\xcb"
" $PROGRAMFILES
if has('win32')
let s:save_isi = &isident
try
set isident+=(,)
let s:arch = exists('$PROGRAMFILES(X86)')
let s:pf64 = exists('$PROGRAMW6432') ?
\ $PROGRAMW6432 : $PROGRAMFILES
let s:pf32 = exists('$PROGRAMFILES(X86)') ?
\ $PROGRAMFILES(X86) : $PROGRAMFILES
finally
let &isident = s:save_isi
unlet! s:save_isi
endtry
endif
" }}}
"------------------------------------------------------------------------------
" Compatibility: {{{
" Vim.Compat.has_version
" 7.4.237 (after 7.4.236) has() not checking for specific patch
if has('patch-7.4.237')
function! s:has_patch(args) abort
return has('patch-' . a:args)
endfunction
else
function! s:has_patch(args) abort
let a = split(a:args, '\.')
let v = a[0] * 100 + a[1]
return v:version > v || v:version == v && has('patch' . a[2])
endfunction
endif
" Check vimproc
function! s:has_vimproc() abort
if !exists('s:_has_vimproc')
try
call vimproc#version()
let s:_has_vimproc = 1
catch
let s:_has_vimproc = 0
endtry
endif
return s:_has_vimproc
endfunction
" dein#tap
function! s:dein_tap(name) abort
return exists('*dein#tap') && dein#tap(a:name)
endfunction
" }}}
" }}}
"==============================================================================
" General: {{{
"------------------------------------------------------------------------------
" System: {{{
" GUI options
set guioptions+=M
" Message
set shortmess+=a
set title
set confirm
" Beep
set errorbells
set novisualbell
set t_vb=
" VimInfo
set history=10000
set viminfo+=n$XDG_CACHE_HOME/viminfo
" Undo file
set undofile
set undodir^=$XDG_CACHE_HOME/vimundo
if !isdirectory($XDG_CACHE_HOME . '/vimundo')
call mkdir($XDG_CACHE_HOME . '/vimundo', 'p')
endif
autocmd MyVimrc BufWritePre *
\ let &undofile = index(s:ignore_ft, &filetype) < 0
" ClipBoard
set clipboard=unnamed
if has('unnamedplus')
set clipboard^=unnamedplus
endif
" Timeout
set timeoutlen=3000
set ttimeoutlen=10
set updatetime=1000
" Hidden buffer
set hidden
" Multi byte charactor width
set ambiwidth=double
" Wild menu
set wildmenu
execute 'set wildignore+=' . join(s:ignore_dir + s:ignore_file, ',')
" Mouse
set mouse=a
set nomousehide
set mousemodel=extend
" }}}
"------------------------------------------------------------------------------
" Display: {{{
" Don't redraw which macro executing
set lazyredraw
" Line number, Ruler, Wrap
set number
set relativenumber
set ruler
set display=lastline
" set scrolloff=5
" Command line
set cmdheight=2
set laststatus=2
set showcmd
" Display NonText
set list
set listchars=eol:$,tab:>-,extends:>,precedes:<
" Help
set helpheight=999
" Conceal
set conceallevel=2
set concealcursor=nc
" }}}
"------------------------------------------------------------------------------
" Search: {{{
" Options
set ignorecase
set smartcase
set incsearch
" Highlight
if s:is_colored_ui
set hlsearch
endif
" Grep
if s:executable('jvgrep')
set grepprg=jvgrep\ -nI
elseif s:executable('grep')
set grepprg=grep\ -nHI
" elseif has('win32')
" set grepprg=findstr\ /n\ /p
else
set grepprg=internal
endif
" }}}
"------------------------------------------------------------------------------
" Edit: {{{
" Complete
set completeopt=menu,menuone
if s:has_patch('7.4.775')
set completeopt+=noselect
endif
set showfulltag
" Format
set nrformats=hex
if s:has_patch('7.4.1027')
set nrformats+=bin
endif
set formatoptions+=m
set formatoptions+=B
" Cursor
set virtualedit=block
set backspace=indent,eol,start
" File format
set fileformat=unix
set fileformats=unix,dos,mac
if s:has_patch('7.4.785')
set nofixendofline
endif
" Indent
set shiftwidth=2
set softtabstop=2
set expandtab
set autoindent
set smartindent
set copyindent
set cinoptions=:0,l1,g0,(0,U1,Ws,j1,J1,)20
" Folding
" set foldcolumn=2
set foldlevelstart=99
" }}}
"------------------------------------------------------------------------------
" Status Line: {{{
set statusline=%f%<\ %m%r[%{empty(&fenc)?&enc:&fenc}:%{&ff}]%y%=
\\ [U+%04B]\ (%l,%v)/%L
if s:is_lang_ja
set statusline+=\ %4P
else
set statusline+=\ %P
endif
" }}}
"------------------------------------------------------------------------------
" Tab Line: {{{
let s:label_noname = s:is_lang_ja ? '[無名]' : '[No Name]'
let s:label_quickfix = s:is_lang_ja ? '[Quickfixリスト]' : '[Quickfix List]'
let s:label_location = s:is_lang_ja ? '[場所リスト]' : '[Location List]'
function! s:label_qflisttype(n) abort
return getbufvar(a:n, 'qflisttype') == 'location' ?
\ s:label_location : s:label_quickfix
endfunction
function! s:tab_bufname(n) abort
let name = bufname(a:n)
let type = getbufvar(a:n, '&buftype')
return
\ type == 'quickfix' ? s:label_qflisttype(a:n) :
\ type == 'help' ? fnamemodify(name, ':t') :
\ empty(name) ? s:label_noname :
\ empty(type) ? pathshorten(name) : name
endfunction
function! s:tab_label(n) abort
let bufs = tabpagebuflist(a:n)
let acv = a:n == tabpagenr()
let win = len(bufs)
let mod = !empty(filter(copy(bufs), 'getbufvar(v:val, "&modified")'))
let name = s:tab_bufname(bufs[tabpagewinnr(a:n) - 1])
return '%' . a:n . 'T' .
\ (acv ? '%#TabLineSel#' : '%#TabLine#') .
\ (win > 1 || mod ? ' ' : '') .
\ (win == 1 ? '' : acv ? ('%#Title#' . win . '%#TabLineSel#') : win) .
\ (mod ? '+' : '') . ' ' . name . ' '
endfunction
function! TabLine() abort
return join(map(range(1, tabpagenr('$')), 's:tab_label(v:val)'), '') .
\ '%#TabLineFill#%T%= %#TabLineSel# ' . getcwd() . ' '
endfunction
set tabline=%!TabLine()
set showtabline=2
" }}}
"------------------------------------------------------------------------------
" File Encodings: {{{
if has('iconv')
if s:has_jisx0213
set fileencodings=iso-2022-jp-3,cp932,euc-jisx0213,euc-jp,ucs-bom
else
set fileencodings=iso-2022-jp,cp932,euc-jp,ucs-bom
endif
if has('guess_encode')
set fileencodings^=guess
endif
let s:last_enc = &encoding
autocmd MyVimrc EncodingChanged *
\ if s:last_enc !=# &encoding |
\ let &runtimepath = iconv(&runtimepath, s:last_enc, &encoding) |
\ let s:last_enc = &encoding |
\ endif
endif
" }}}
"------------------------------------------------------------------------------
" Cursor Line: {{{
if s:is_colored_ui
set cursorline
set cursorcolumn
" No cursor line & column at other window
augroup MyVimrc
autocmd BufWinEnter,WinEnter *
\ let [&cursorline, &cursorcolumn] =
\ [!get(b:, 'nocursorline'), !get(b:, 'nocursorcolumn')]
autocmd BufWinLeave,WinLeave *
\ setlocal nocursorline nocursorcolumn
augroup END
endif
" }}}
"------------------------------------------------------------------------------
" Multi Mode Mapping: {{{
command! -nargs=* -complete=mapping
\ NOmap
\ nmap <args>| omap <args>
command! -nargs=* -complete=mapping
\ NVmap
\ nmap <args>| vmap <args>
command! -nargs=* -complete=mapping
\ NXmap
\ nmap <args>| xmap <args>
command! -nargs=* -complete=mapping
\ NSmap
\ nmap <args>| smap <args>
command! -nargs=* -complete=mapping
\ OVmap
\ omap <args>| vmap <args>
command! -nargs=* -complete=mapping
\ OXmap
\ omap <args>| xmap <args>
command! -nargs=* -complete=mapping
\ OSmap
\ omap <args>| smap <args>
command! -nargs=* -complete=mapping
\ NOXmap
\ nmap <args>| omap <args>| xmap <args>
command! -nargs=* -complete=mapping
\ NOSmap
\ nmap <args>| omap <args>| smap <args>
command! -nargs=* -complete=mapping
\ NOnoremap
\ nnoremap <args>| onoremap <args>
command! -nargs=* -complete=mapping
\ NVnoremap
\ nnoremap <args>| vnoremap <args>
command! -nargs=* -complete=mapping
\ NXnoremap
\ nnoremap <args>| xnoremap <args>
command! -nargs=* -complete=mapping
\ NSnoremap
\ nnoremap <args>| snoremap <args>
command! -nargs=* -complete=mapping
\ OVnoremap
\ onoremap <args>| vnoremap <args>
command! -nargs=* -complete=mapping
\ OXnoremap
\ onoremap <args>| xnoremap <args>
command! -nargs=* -complete=mapping
\ OSnoremap
\ onoremap <args>| snoremap <args>
command! -nargs=* -complete=mapping
\ NOXnoremap
\ nnoremap <args>| onoremap <args>| xnoremap <args>
command! -nargs=* -complete=mapping
\ NOSnoremap
\ nnoremap <args>| onoremap <args>| snoremap <args>
command! -nargs=* -complete=mapping
\ NVunmap
\ nunmap <args>| vunmap <args>
command! -nargs=* -complete=mapping
\ NXunmap
\ nunmap <args>| xunmap <args>
command! -nargs=* -complete=mapping
\ NSunmap
\ nunmap <args>| sunmap <args>
command! -nargs=* -complete=mapping
\ NOunmap
\ nunmap <args>| ounmap <args>
command! -nargs=* -complete=mapping
\ OVunmap
\ ounmap <args>| vunmap <args>
command! -nargs=* -complete=mapping
\ OXunmap
\ ounmap <args>| xunmap <args>
command! -nargs=* -complete=mapping
\ OSunmap
\ ounmap <args>| sunmap <args>
command! -nargs=* -complete=mapping
\ NOXunmap
\ nunmap <args>| ounmap <args>| xunmap <args>
command! -nargs=* -complete=mapping
\ NOSunmap
\ nunmap <args>| ounmap <args>| sunmap <args>
" }}}
" }}}
"==============================================================================
" Macros: {{{
" Source macros
if has('packages')
function! s:source_macros(name) abort
silent! execute 'packadd' a:name
endfunction
else
function! s:source_macros(name) abort
silent! execute 'source' $VIMRUNTIME . '/macros/' . a:name . '.vim'
endfunction
endif
"------------------------------------------------------------------------------
" MatchIt: {{{
call s:source_macros('matchit')
if exists('g:loaded_matchit')
silent! sunmap %
silent! sunmap g%
silent! sunmap [%
silent! sunmap ]%
silent! sunmap a%
NXmap <SID>[% [%
NXmap <SID>]% ]%
xnoremap <script> [% <Esc><SID>[%m'gv``
xnoremap <script> ]% <Esc><SID>]%m'gv``
xnoremap <script> a% <Esc><SID>[%v<SID>]%
NOXmap <Space> %
NOXmap <S-Space> g%
endif
" }}}
" }}}
"==============================================================================
" Mappings: {{{
"------------------------------------------------------------------------------
" Common: {{{
" <Leader> <LocalLeader>
let g:mapleader = ';'
let g:maplocalleader = ','
NOXnoremap <Leader> <Nop>
NOXnoremap <LocalLeader> <Nop>
" For mark
NOXnoremap m <Nop>
NOXnoremap M <Nop>
" For user operator
NOXnoremap s <Nop>
NOXnoremap S <Nop>
" " For user textobj
" OXnoremap <M-a> <Nop>
" OXnoremap <M-A> <Nop>
" OXnoremap <M-i> <Nop>
" OXnoremap <M-I> <Nop>
" " For user square
" NOXnoremap <M-[> <Nop>
" NOXnoremap <M-]> <Nop>
" For the evacuation of "g"
NOnoremap <C-G> <Nop>
" Split Nicely
noremap <expr> <SID>(split)
\ myvimrc#split_direction() ? '<C-W>s' : '<C-W>v'
" }}}
"------------------------------------------------------------------------------
" Command Line: {{{
NOXnoremap <expr> <SID>: myvimrc#cmdline_enter(':')
NXnoremap <expr> <SID>/ myvimrc#cmdline_enter('/')
NXnoremap <expr> <SID>? myvimrc#cmdline_enter('?')
NOXmap ;; <SID>:
NOXmap : <SID>:
NXmap / <SID>/
NXmap ? <SID>?
NOXnoremap <expr> ;: myvimrc#cmdline_enter(':')
NXnoremap <expr> ;/ myvimrc#cmdline_enter('/')
NXnoremap <expr> ;? myvimrc#cmdline_enter('?')
NXnoremap <script> <C-W>/ <SID>(split)<SID>/
NXnoremap <script> <C-W>? <SID>(split)<SID>?
NXnoremap <script> <C-W>q/ <SID>(split)q/
NXnoremap <script> <C-W>q? <SID>(split)q?
NXnoremap <script><expr> <C-W>;/
\ '<SID>(split)' . myvimrc#cmdline_enter('/')
NXnoremap <script><expr> <C-W>;?
\ '<SID>(split)' . myvimrc#cmdline_enter('?')
cnoremap <expr> / getcmdtype() == '/' ? '\/' : '/'
cnoremap <expr> ? getcmdtype() == '?' ? '\?' : '?'
augroup MyVimrc
autocmd CmdwinEnter *
\ call myvimrc#cmdwin_enter(expand('<afile>'))
autocmd CmdwinLeave *
\ call myvimrc#cmdwin_leave(expand('<afile>'))
augroup END
" }}}
"------------------------------------------------------------------------------
" Search: {{{
noremap <SID>* *zv
noremap <SID># #zv
noremap <SID>g* g*zv
noremap <SID>g# g#zv
noremap <SID>n nzv
noremap <SID>N Nzv
NOXmap * <SID>*
NOXmap # <SID>#
NOXmap g* <SID>g*
NOXmap g# <SID>g#
NOXmap g/ *
NOXmap g? #
nmap <C-W>* <SID>(split)<SID>*
nmap <C-W># <SID>(split)<SID>#
nmap <C-W>g* <SID>(split)<SID>g*
nmap <C-W>g# <SID>(split)<SID>g#
xnoremap <script> <C-W>* <SID>(split)gv<SID>*
xnoremap <script> <C-W># <SID>(split)gv<SID>#
xnoremap <script> <C-W>g* <SID>(split)gv<SID>g*
xnoremap <script> <C-W>g# <SID>(split)gv<SID>g#
NXmap <C-W>g/ <C-W>*
NXmap <C-W>g? <C-W>#
NOXmap <expr> n v:searchforward ? '<SID>n' : '<SID>N'
NOXmap <expr> N v:searchforward ? '<SID>N' : '<SID>n'
" }}}
"------------------------------------------------------------------------------
" Escape Key: {{{
nnoremap <expr> <Esc><Esc> myvimrc#escape_key()
" }}}
"------------------------------------------------------------------------------
" Moving: {{{
" Jump
nnoremap <S-Tab> <C-O>
" Mark
NOXnoremap m<Down> ]`
NOXnoremap m<Up> [`
NOXnoremap mj ]`
NOXnoremap mk [`
" Command-line-mode
cnoremap <C-A> <C-B>
cnoremap <expr> <C-H>
\ getcmdtype() == '@' && getcmdpos() == 1 && empty(getcmdline()) ?
\ '<Esc>' : '<C-H>'
cnoremap <expr> <BS>
\ getcmdtype() == '@' && getcmdpos() == 1 && empty(getcmdline()) ?
\ '<Esc>' : '<BS>'
cnoremap <expr> <Esc>
\ &cpoptions =~# 'x' ?
\ '<Esc>' : '<C-E><C-U><C-C>'
cnoremap <C-C> <C-E><C-U><C-C>
" }}}
"------------------------------------------------------------------------------
" Window Control: {{{
NXnoremap <M-s> <C-W>s
NXnoremap <M-v> <C-W>v
NXnoremap <M-j> <C-W>j
NXnoremap <M-k> <C-W>k
NXnoremap <M-h> <C-W>h
NXnoremap <M-l> <C-W>l
NXnoremap <M-J> <C-W>J
NXnoremap <M-K> <C-W>K
NXnoremap <M-H> <C-W>H
NXnoremap <M-L> <C-W>L
NXnoremap <M-=> <C-W>=
NXnoremap <M--> <C-W>-
NXnoremap <M-+> <C-W>+
NXnoremap <M-_> <C-W>_
NXnoremap <M-<> <C-W><
NXnoremap <M->> <C-W>>
NXnoremap <M-Bar> <C-W><Bar>
" }}}
"------------------------------------------------------------------------------
" Leader Prefix: {{{
NXnoremap <Leader>c :<C-U>close<CR>
NXnoremap <Leader><M-c> :<C-U>tabclose<CR>
NXnoremap <Leader>C :<C-U>only<CR>
NXnoremap <Leader><M-C> :<C-U>tabonly<CR>
NXnoremap <Leader>n :<C-U>enew<CR>
NXnoremap <Leader><M-n> :<C-U>tabnew<CR>
NXnoremap <Leader>w :<C-U>update<CR>
NXnoremap <Leader>W :<C-U>wall<CR>
NXnoremap <Leader>q :<C-U>bdelete<CR>
NXnoremap <Leader>E :<C-U>Explorer<CR>
NXnoremap <Leader>B :<C-U>buffers<CR>
NXnoremap <Leader>T :<C-U>tabs<CR>
NXnoremap <Leader>U :<C-U>undolist<CR>
NXnoremap <Leader>j :<C-U>changes<CR>
NXnoremap <Leader>J :<C-U>jumps<CR>
NXnoremap <Leader>p :<C-U>registers<CR>
NXnoremap <Leader>m :<C-U>marks<CR>
NXnoremap <Leader>! :<C-U>shell<CR>
NXnoremap <script> <Leader>e <SID>:<C-U>edit<Space>
NXnoremap <script> <Leader>b <SID>:<C-U>buffer<Space>
NXnoremap <script> <Leader>t <SID>:<C-U>tabnext<Space>
NXnoremap <script> <Leader>u <SID>:<C-U>undo<Space>
NXnoremap <script> <Leader>] <SID>:<C-U>tag<Space>
NXnoremap <script> <Leader>d <SID>:<C-U>lchdir<Space>
NXnoremap <script> <Leader>D <SID>:<C-U>chdir<Space>
NXnoremap <script> <Leader>g <SID>:<C-U>grep<Space>
NXnoremap <script> <Leader>G <SID>:<C-U>lgrep<Space>
NXnoremap <expr> <Leader>Q
\ ':<C-U>1,' . bufnr('$') . 'bdelete<CR>'
NXnoremap <script><expr> <Leader><M-d>
\ '<SID>:<C-U>lchdir ' . compat#expand_slash('%:p:h') . '/'
NXnoremap <script><expr> <Leader><M-D>
\ '<SID>:<C-U>chdir ' . compat#expand_slash('%:p:h') . '/'
" }}}
"------------------------------------------------------------------------------
" Help: {{{
nnoremap <script><expr> <F1>
\ myvimrc#split_direction() ?
\ '<SID>:<C-U>help<Space>' :
\ '<SID>:<C-U>vertical help<Space>'
inoremap <script><expr> <F1>
\ myvimrc#split_direction() ?
\ '<C-O><SID>:<C-U>help<Space>' :
\ '<C-O><SID>:<C-U>vertical help<Space>'
" }}}
"------------------------------------------------------------------------------
" Auto Mark: {{{
nnoremap <expr> mm myvimrc#auto_mark()
nnoremap <expr> mc myvimrc#clear_marks()
nnoremap <expr> mM myvimrc#auto_file_mark()
nnoremap <expr> mC myvimrc#clear_file_marks()
" }}}
"------------------------------------------------------------------------------
" BOL Toggle: {{{
NOXnoremap <expr> H myvimrc#bol_toggle()
NOXnoremap <expr> L myvimrc#eol_toggle()
" }}}
"------------------------------------------------------------------------------
" Insert One Character: {{{
nnoremap <expr> <M-a> myvimrc#insert_one_char('a')
NXnoremap <expr> <M-A> myvimrc#insert_one_char('A')
nnoremap <expr> <M-i> myvimrc#insert_one_char('i')
NXnoremap <expr> <M-I> myvimrc#insert_one_char('I')
" }}}
"------------------------------------------------------------------------------
" Blockwise Insert: {{{
xnoremap <expr> A myvimrc#blockwise_insert('A')
xnoremap <expr> I myvimrc#blockwise_insert('I')
" }}}
"------------------------------------------------------------------------------
" Increment: {{{
silent! vunmap <C-A>
silent! vunmap <C-X>
if s:has_patch('7.4.754')
xnoremap <C-A> <C-A>gv
xnoremap <C-X> <C-X>gv
xnoremap g<C-A> g<C-A>gv
xnoremap g<C-X> g<C-X>gv
endif
" }}}
"------------------------------------------------------------------------------
" Others: {{{
" Paste
set pastetoggle=<F11>
nnoremap <F11> :<C-U>set paste! paste?<CR>
" BackSpace
nnoremap <BS> X
nnoremap <C-H> X
" Yank to end of line
nnoremap Y y$
" Tabmove
NXnoremap <expr> g<M-t>
\ ':<C-U>tabmove +' . v:count1 . '<CR>'
NXnoremap <expr> g<M-T>
\ ':<C-U>tabmove -' . v:count1 . '<CR>'
" Append line
nnoremap <M-o>
\ :<C-U>call append(line('.'), repeat([''], v:count1))<CR>
nnoremap <M-O>
\ :<C-U>call append(line('.') - 1, repeat([''], v:count1))<CR>
" The precious area text object
onoremap gv :<C-U>normal! gv<CR>
" The last changed area text object
nnoremap g[ `[v`]
OXnoremap g[ :<C-U>normal g[<CR>
" }}}
"------------------------------------------------------------------------------
" Evacuation: {{{
" Mark
nnoremap <M-m> m
" Repeat find
NOXnoremap <M-;> ;
NOXnoremap <M-,> ,
" Jump
NOXnoremap gH H
NOXnoremap gM M
NOXnoremap gL L
" FileInfo
nnoremap <C-G><C-G> <C-G>
" To Select-mode
nnoremap <C-G>h gh
nnoremap <C-G>H gH
nnoremap <C-G><C-H> g<C-H>
" Macro
NXnoremap <M-q> q
NXnoremap Q @
NXnoremap Q; @:
NXnoremap QQ @@
" Dangerous key
nnoremap ZQ <Nop>
nnoremap ZZ <Nop>
nnoremap gQ gq
inoremap <C-C> <Esc>
" Rot13
NOXnoremap s? g?
nnoremap s?? g??
" }}}
" }}}
"==============================================================================
" Commands: {{{
"------------------------------------------------------------------------------
" Change Indent Option: {{{
command! -bar
\ IndentTab4
\ setlocal shiftwidth=4 tabstop=4 softtabstop=4 noexpandtab
command! -bar
\ IndentTab8
\ setlocal shiftwidth=8 tabstop=8 softtabstop=8 noexpandtab
command! -bar
\ IndentSpace2
\ setlocal shiftwidth=2 softtabstop=2 expandtab
command! -bar
\ IndentSpace4
\ setlocal shiftwidth=4 softtabstop=4 expandtab
command! -bar
\ IndentSpace8
\ setlocal shiftwidth=8 softtabstop=8 expandtab
" }}}
"------------------------------------------------------------------------------
" Change File Format Option: {{{
command! -bar
\ FfUnix
\ setlocal fileformat=unix
command! -bar
\ FfDos
\ setlocal fileformat=dos
command! -bar
\ FfMac
\ setlocal fileformat=mac
" }}}
"------------------------------------------------------------------------------
" Change File Encoding Option: {{{
command! -bar
\ FencUtf8
\ setlocal fileencoding=utf-8 nobomb
command! -bar
\ FencUtf16le
\ setlocal fileencoding=utf-16le bomb
command! -bar
\ FencUtf16
\ setlocal fileencoding=utf-16 bomb
command! -bar
\ FencCp932
\ setlocal fileencoding=cp932
command! -bar
\ FencEucjp
\ setlocal fileencoding=euc-jp
if s:has_jisx0213
command! -bar
\ FencEucJisx0213
\ setlocal fileencoding=euc-jisx0213
command! -bar
\ FencIso2022jp
\ setlocal fileencoding=iso-2022-jp-3
else
command! -bar
\ FencIso2022jp
\ setlocal fileencoding=iso-2022-jp
endif
" }}}
"------------------------------------------------------------------------------
" Open With A Specific Character Code Again: {{{
command! -bang -bar -nargs=* -complete=file
\ EditUtf8
\ edit<bang> ++enc=utf-8 <args>
command! -bang -bar -nargs=* -complete=file
\ EditUtf16le
\ edit<bang> ++enc=utf-16le <args>
command! -bang -bar -nargs=* -complete=file
\ EditUtf16
\ edit<bang> ++enc=utf-16 <args>
command! -bang -bar -nargs=* -complete=file
\ EditCp932
\ edit<bang> ++enc=cp932 <args>
command! -bang -bar -nargs=* -complete=file
\ EditEucjp
\ edit<bang> ++enc=euc-jp <args>
if s:has_jisx0213
command! -bang -bar -nargs=* -complete=file
\ EditEucJisx0213
\ edit<bang> ++enc=euc-jisx0213 <args>
command! -bang -bar -nargs=* -complete=file
\ EditIso2022jp
\ edit<bang> ++enc=iso-2022-jp-3 <args>
else
command! -bang -bar -nargs=* -complete=file
\ EditIso2022jp
\ edit<bang> ++enc=iso-2022-jp <args>
endif
" }}}
"------------------------------------------------------------------------------
" Windows Shell: {{{
if has('win32')
command! -bar
\ ShellCmd
\ call myvimrc#set_shell() |
\ set shell? shellcmdflag? shellquote? shellxquote? shellslash?
command! -bar -nargs=?
\ ShellSh
\ call myvimrc#set_shell(
\ !empty(<q-args>) ? <q-args> : 'sh', '-c', '', '"', 1) |
\ set shell? shellcmdflag? shellquote? shellxquote? shellslash?