-
Notifications
You must be signed in to change notification settings - Fork 2
/
.vimrc
3114 lines (2565 loc) · 106 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
" vim: set fdm=marker sw=2 sts=2 cms="%s :
"=============================================================================
"init
"-----------------------------------------------------------------------------
"Encodings, Formats"{{{
scriptencoding utf8 "このファイルのエンコード
if has("win32")
se tenc =cp932 "Ref.vimでlynxがデフォルトで使うエンコード
endif
se encoding=utf8
se fileencodings=utf8,cp932,iso-2022-jp,euc-jp,default,latin
"<< BufRead時、'fileencodings'の先頭から'encoding'を試してerrが出なければそれを適用する
"改行コードの自動認識(新規作成されるファイルフォーマットをdosにしたい)
se fileformats=dos,unix,mac
"---
"setglobal fileencoding=cp932 "新規作成されるファイルエンコードをcp932にしたい
"}}}
"環境変数を作る"{{{
"$HOME がないとき、$VIM/TMPHOME を $HOME にする "{{{
if !exists("$HOME")
let $HOME=$VIM. '/TMPHOME'
endif
"}}}
"$VIMFILES "{{{
if has('vim_starting')
if isdirectory(expand('$HOME/vimfiles', ':p'))
let $VIMFILES = $HOME. '/vimfiles'
set runtimepath+=$HOME/vimfiles/neobundle/neobundle.vim
call neobundle#rc(expand('$HOME/vimfiles/neobundle'))
else
let $VIMFILES = $VIM. '/vimfiles'
set runtimepath+=$VIM/vimfiles/neobundle/neobundle.vim
call neobundle#rc(expand('$VIM/vimfiles/neobundle'))
endif
endif
"}}}
"}}}
"-----------------------------------------------------------------------------
"Plugins init setting
"sow.vim
"map ,s <Plug>(sow_start)
let g:sow_dc = '~/.sow_dc/.old'
"neobundle.vim"{{{
filetype off
"$VIMFILES参照; neobundle#rc()の実行
"--------------------------------------
"拡張インターフェイス
NeoBundle 'Shougo/unite.vim'
NeoBundleLazy 'kien/ctrlp.vim'
NeoBundle 'Shougo/vimshell'
NeoBundle 'Shougo/vimfiler', {'depends': 'Shougo/unite.vim'}
NeoBundle 'tsukkee/lingr-vim'
NeoBundle 'tpope/vim-fugitive'
NeoBundle 'pocket7878/presen-vim', {'depends': 'pocket7878/curses-vim'}
NeoBundle 'thinca/vim-showtime'
NeoBundle 'thinca/vim-ref'
NeoBundle 'thinca/vim-quickrun'
"NeoBundle 'mattn/gist-vim'
"exe "NeoBundle 'mrtazz/simplenote.vim'" | "オンラインノートsimplenoteを使う
"exe "NeoBundle 'gregsexton/gitv'" | "vim版Gitk()
"exe "NeoBundle 'tomtom/ttoc_vim', {'depends': 'tomtom/tlib_vim'}" | "アウトライナ
"exe "NeoBundle 'kien/ctrlp.vim'" | "カレントファイルにアクセスする
"NeoBundle 'vim-scripts/vimwiki'
"NeoBundle 'https://github.com/fuenor/qfixhowm.git'
"--------------------------------------
"ライブラリ
NeoBundle 'Shougo/vimproc'
NeoBundle 'tomtom/tlib_vim'
exe 'NeoBundle "vim-jp/vital.vim"' | "最近なぜかNeoBundleからアップデートできない
exe "NeoBundle 'thinca/vim-openbuf'" | "unite-vim_hacksがこれに依存
"exe "NeoBundle 'mattn/wwwrenderer-vim'" | "webpage(only text)を返す
"exe "NeoBundle 'mattn/webapi-vim'" | "
NeoBundle 'pocket7878/curses-vim'
"--------------------------------------
"環境
"exe "NeoBundle 'kana/vim-tabpagecd'" | "TabPage毎にcrrdirを持てるようにする
NeoBundle 'tyru/open-browser.vim'
NeoBundle 'Shougo/neobundle.vim'
NeoBundle 'tpope/vim-pathogen'
NeoBundle 'kana/vim-submode'
"exe "NeoBundle 'thinca/vim-localrc'" | "特定dir以下に.lvimrcを置くとdir以下のfileだけで設定反映
NeoBundle 'Rykka/lastbuf.vim'
NeoBundle 'LeafCage/revolver.vim'
"--------------------------------------
"拡張文章
"NeoBundle 'vim-jp/vimdoc-ja'
exe "NeoBundle 'https://github.com/ujihisa/mdv.git'" | "VimHacksで使われている拡張Markdown
NeoBundleLazy 'motemen/hatena-vim'
"--------------------------------------
"入力・移動
NeoBundle 'Shougo/neocomplcache'
NeoBundle 'Shougo/neocomplcache-snippets-complete', {'depends': 'Shougo/neocomplcache'}
NeoBundle 'kana/vim-textobj-user'
exe "NeoBundle 'h1mesuke/textobj-wiw'" | "カーソルドのwordを選択する/ CamelCaseMotionの働きも?
NeoBundle 'kana/vim-textobj-indent'
exe "NeoBundle 'thinca/vim-textobj-plugins'" | "中身はtextobj-between
NeoBundle 'anyakichi/vim-textobj-xbrackets'
NeoBundle 'anyakichi/vim-surround'
NeoBundle 'scrooloose/nerdcommenter'
"NeoBundle 'tomtom/tcomment_vim'
NeoBundle 'bkad/CamelCaseMotion'
"NeoBundle 'kana/vim-smartword'
"NeoBundle 'kana/vim-smartchr'
exe "NeoBundle 'thinca/vim-poslist'" | "Bible 3-13
exe "NeoBundle 'thinca/vim-visualstar'" | " *検索 #B3-14
exe "NeoBundleLazy 'https://github.com/vim-scripts/DrawIt.git'" | "図を描写する #Bible5-4
exe "NeoBundleLazy 'https://github.com/vim-scripts/Align.git'" | "高機能なテキストファイル整形ツール #Bible5-11
NeoBundleLazy 'https://github.com/tpope/vim-speeddating.git'
"--------------------------------------
"コマンドライン
exe "NeoBundle 'thinca/vim-ambicmd'" | "コマンド名省入力 ex)NeoBundleUpdate > NBU
exe "NeoBundle 'tyru/vim-altercmd'" | "コマンドのエイリアスを作る tyru版あり #B9-6
"--------------------------------------
"情報表示
exe "NeoBundle 'tacroe/unite-mark'" | "マーク一覧を表示
exe "NeoBundle 'tsukkee/unite-tag'" |
exe "NeoBundle 'tsukkee/unite-help'" |
NeoBundle 'tyru/current-func-info.vim'
exe "NeoBundle 'https://github.com/ujihisa/neco-look.git'" | "要look.exe
NeoBundle 'h1mesuke/unite-outline'
"NeoBundle 'Shougo/echodoc'
"NeoBundleLazy 'choplin/unite-vim_hacks', {'depends', 'thinca/vim-openbuf'}
NeoBundle 'rbtnn/sign.vim'
"--------------------------------------
"GUI操作
exe "NeoBundle 't9md/vim-quickhl'" | "複数の検索ハイライト
NeoBundle 'tyru/winmove.vim'
NeoBundle 'thinca/vim-fontzoom'
"exe "NeoBundle 'ujihisa/unite-font'" | "動かない
exe "NeoBundle 'ujihisa/unite-colorscheme'" |
NeoBundle 'pasela/unite-webcolorname'
filetype plugin indent on "ファイル判定をonにする
"}}}
"pathogen.vim"{{{
filetype off "一度ファイル判定をoffにしないとftdetectをロードしてくれないので。
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
filetype plugin indent on "ファイル判定をonにする
"}}}
call altercmd#load() "altercmdをこのvimrc内で有効にする
"-----------------------------------------------------------------------------
"マウスを有効にする"{{{
if has('mouse')
se mouse=a
endif
"}}}
"-----------------------------------------------------------------------------
"Backup"{{{
"backupfile "{{{
":h backup-table
se nobk nowb
"NOTE: 'nobk'で'wb'だと書き込みに失敗したときのみbackupfileが残される
se bex=.bcu
se bdir=/tmp/auBcu/,.
if !isdirectory(&bdir)
call mkdir(&bdir, "p")
endif
"}}}
"swapfile "{{{
se swf
se dir=~/vimswap/,.
if !isdirectory(&dir)
call mkdir(&dir, "p")
endif
"}}}
"undofile"{{{
if version >= 703
se undofile
let &udir = &bdir
endif
"}}}
"viminfofile "{{{
se vi=
se vi+='20 "marks
se vi+=<50 "register limit (line)
se vi+=s10 "register limit (Kbyte)
se vi+=% "buffers list
se vi+=h "viminfoを読み込むとき 'hlsearch' を無効にする
se vi+=ra:,rb: "removable mediaの指定 (mark履歴対象外にする)
"se vi+=n$VIM/.viminfo "viminfo file name (作成する場所)
se vi+=n~/.viminfo "viminfo file name (作成する場所)
"}}}
"}}}
"=============================================================================
"編集設定
"-----------------------------------------------------------------------------
"Indent, 自動整形"{{{
se et ts=2 sts=2 sw=2 ai
"'ts' 見かけ
"'sts' <Tab>の挿入や<BS>の使用等の編集操作
"'sw' 'ci'や'ai'や>>で挿入されるindent
"行継続の際、挿入されるindent量 :h ft-vim-indent
let g:vim_indent_cont = &sw
se cin cino& cino+=:0
"< 'cino' については実際使うときになって考え直す必要性 :h cinoptions-values
se smartindent
"auto-format
se formatoptions=
"se fo +=t "'textwidth' を使ってテキストを自動折返しする
se fo +=q ""gq" でコメントを整形する。
se fo +=n "番号付きリスト等を認識して折り返す
se fo +=M "マルチバイト文字連結時空白を挿入しない
se fo +=m "マルチバイト文字でも整形を有効にする
"改行時にコメントしない(上手く動いていない(上書きされてる))
"aug vimrc_fo
" au!
" au FileType * setlocal fo-=ro
"aug END
"}}}
"-----------------------------------------------------------------------------
"検索"{{{
se ws hls is
se tags=./tags,tags,../tags "tagsファイルの読み込み先
"grepコマンドで使うプログラムを何にするか
"set grepprg=internal " vimgrep をデフォルトのgrepとする場合internal
"set grepprg=D:/bnr/cmd/cygwingrep/bin/cyggrep.exe\ -nH ""-n;:行番表示-H;:ファイル名表示
set grepprg=jvgrep ""-n;:行番表示-H;:ファイル名表示
"set grepprg=cyggrep.exe\ -nH
"}}}
"-----------------------------------------------------------------------------
"書き込み・終了"{{{
":w等でどこにファイルを保存するか
set browsedir=buffer
" 他で書き換えられたら自動で読み直す
set autoread
" バッファへの変更を保存しないで終了するとき、確認する
set confirm
"}}}
"-----------------------------------------------------------------------------
"Window
se lines=40 co=100
"se scrolloff=2
se hh=0 pvh=0 ea
se wmw=0
se ch=2 "コマンドラインの高さ
" Window位置の保存と復帰 "{{{
if has('gui_running')
if has('unix')
let s:infofile = '~/.vim/.vimpos'
else
let s:infofile = '$VIM/.vimpos'
endif
augroup WinPosSizeSaver
au!
augroup END
exe 'au WinPosSizeSaver VimLeave * call s:WinPosSizeSave("'.s:infofile.'")'
if filereadable(expand(s:infofile))
execute 'source '.s:infofile
endif
unlet s:infofile
endif
function! s:WinPosSizeSave(filename)"{{{
let saved_reg = @a
redir @a
winpos
redir END
let px = substitute(@a, '.*X \(\d\+\).*', '\1', '') + 0
let py = substitute(@a, '.*Y \(\d\+\).*', '\1', '') + 0
exe 'redir! >'.a:filename
if px > 0 && py > 0
echo 'winpos '.px.' '.py
endif
echo 'set lines='.&lines.' columns='.&columns
redir END
let @a = saved_reg
endfunction
"}}}
"}}}
"-----------------------------------------------------------------------------
"カーソルの挙動"{{{
"実際に文字がないところにカーソルを置けるようにする
se ve =block,onemore
"カーソル左右の動き
se ww=
se ww+=b "<BS>
se ww+=s "<Space>
se ww+=h
se ww+=l
se ww+=< "<Left> (nv)
se ww+=> "<Right> (nv)
se ww+=[ "<Left> (i Replace)
se ww+=] "<Right> (i Replace)
"<BS>等をindentやeolを越えて有効にする
se bs=indent,eol,start
"}}}
" ファイルを開いたら前回のカーソル位置へ移動 TODO:mkviewに置き換える
aug vimrc_ex
au!
au BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line('$') |
\ exe "normal! g`\"" |
\ endif
aug END
"-----------------------------------------------------------------------------
"その他挙動
"AltKeyでmenuにアクセスするか
se wak =no
"keybind timeout
se to tm=5000 ttm=100
"<C-a><C-x>に影響
se nf=hex
se history=50 "コマンド履歴保存数
se clipboard=
se modeline
se wrap " 行を折り返す
se sm mat=1 "括弧の対応表示時間
"=============================================================================
"特殊UI
"補完を有効にする
set completeopt=menu,menuone,longest,preview
"折り畳み
se fdm=marker cms=%s fdc=5 fdt=FoldCCtext()
"-----------------------------------------------------------------------------
"Statusline
se stl =%!Gs_StatusLine()
"au WinEnter * setl stl=%!Gs_StatusLine()
let g:shujuu_top = 1
let g:shujuu_bottom = 5
function! Gs_StatusLine() "{{{
let crrbuf_head = '%{empty(bufname("%")) ? "" : expand(''%:p:h'')."/"}'
let crrbuf_tail = '%9*%t %0*' "< tail の highlight を変えている :h hl-User1
let crrbuf_path = crrbuf_head .crrbuf_tail
let fenc8ff = '[%{&fenc}/%{&ff[:0]}]'
let info = ''
if exists('*cfi#format')
let info .= '%8*%{cfi#format("%.43s()" ,"")}%0*'
endif
let funclnum = s:__gi_funclnum()
let info .= '%8*%{exists("b:vimfiler.current_dir")?b:vimfiler.current_dir :""}%0*'
let win_shujuukankei = ['天', '主', '副', '平', '僕', '隷']
return
\ '%3(%{repeat(",", winnr()).","}'. '%{'.string(win_shujuukankei).'[exists("b:shujuu_overtaker")?0:w:shujuu]}%*%)'.
\ '%3n-'. '%.40('. crrbuf_path. '%)'.
\ '%m%R%H%W%y %('. fenc8ff .'%) '.
\ info . funclnum. '%='.
\ '%14(~%L~ %l,%v%)%< %P'
"\ '['. '%{winnr()}'. '%7*%{'.string(win_shujuukankei).'[w:shujuu]}%*'. ']'.
"\ '%#%{ShujuuColor()}#'. '%{g:win_shujuukankei[w:shujuu]}%*'. '%13([%L] %l,%v%)%< %P'
"\ '%#ShujuuMaster#'. '%{g:win_shujuukankei[w:shujuu]}%*'. '%13([%L] %l,%v%)%< %P'
endfunction
"}}}
"関数定義始まりから見た行数を返す >
function! s:__gi_funclnum() "{{{
let funcdef = search('^\s*\<fu\%[nction]\>', 'bcnW', search('^\s*\<endf\%[unction]\>', 'bcnW'))
if funcdef > 0
return ' '.(line('.') - funcdef).' '
else
return ''
endif
endfunction
"}}}
"挿入モード時、ステータスラインのカラー変更
let g:hi_insert = 'hi StatusLine guifg=black guibg=darkyellow gui=bold ctermfg=blue ctermbg=yellow cterm=bold'
if has('syntax')
syntax on
augroup InsertHook
au!
au InsertEnter * call s:Cng_stlColor('Enter')
au InsertLeave * call s:Cng_stlColor('Leave')
augroup END
endif
"i_CTRL-cでstatusLineの色が変更されない問題を修正
inoremap <silent><C-c> <C-c>:call <SID>Cng_stlcolor('Leave')<CR>
let s:slhlcmd = ''
function! s:Cng_stlColor(mode) "{{{
if a:mode == 'Enter'
silent! let s:slhlcmd = 'highlight ' . s:__Gs_hi('StatusLine')
silent exec g:hi_insert
else
highlight clear StatusLine
silent exec s:slhlcmd
endif
endfunction
"}}}
"-----------------------------------------------------------------------------
"TabLine
se stal=2 "常に tabline を表示
se tal=%!Gs_TabLine()
let g:TDD_idx = 0
noremap <silent>[C-k]td :let g:TDD_idx = g:TDD_idx>=3 ?0 :g:TDD_idx+1<CR><C-l>
function! Gs_TabLine() "{{{
let one2tabpEnd = range(1, tabpagenr('$'))
let titles = map(one2tabpEnd, 's:__Gs_Tabpage_label(v:val)')
let sep = ' ' "タブ間の区切り
let tabpages = join(titles, sep) . sep . '%#TabLineFill#%T'
let info = '' " 好きな情報を入れる {{{
"FoldCCnavi
if exists('*FoldCCnavi')
let info .= '%#TabLineInfo#'.substitute(strtrans(substitute(FoldCCnavi()[-70:],'\s>\s','%#TabLineFill#> %#TabLineInfo#','g')), '<\x\x>','','g') . '%0* '
"let info .= '%#TabLineInfo#%.60('.substitute(FoldCCnavi(),'\s>\s',' >','g').'%)%0* '
endif
"Keyswitcherの状態
let info .= g:keyswitcher_modes[g:Keyswitcher_mode_idx]. ' '
"テスト駆動開発の4モードを表示
let info .= ['%#TDD_Think#Tnk%*', '%#TDD_Red#Red%*', '%#TDD_Green#Grn%*', '%#TDD_Refactor#Rfc%*'][g:TDD_idx]. ' '
"gitのブランチ名表示
"let branch_name = s:vcs_branch_name(getcwd())
"let info .= (branch_name != '' ? branch_name : '?')
"カレントバッファの総行数
"let info .= '%L'
let info .= 'tw%{&tw}'
"カレントディレクトリ
let info .= '[%.35('.fnamemodify(getcwd(), ":~") . '%)]'
"}}}
return tabpages . '%=' . info.'' " タブリストを左に、情報を右に表示
endfunction
"}}}
function! s:__Gs_Tabpage_label(tabpagenr) "{{{
"rol;各タブページのカレントバッファ名+αを表示
let title = gettabvar(a:tabpagenr, 'title') "タブローカル変数 t:title を取得
"<< t:titleを設定していたっけ俺?(されているなら抜けるらしいが)
if title !=# ''
return title
endif
" カレントタブページかどうかでハイライトを切り替える
let hiTabLable = a:tabpagenr is tabpagenr() ? '%#TabLineSel#' : '%#TabLine#'
"let hiWinnum = a:tabpagenr is tabpagenr() ? '%#TabLineSelWinnum#' : '%#TabLineWinnum#'
" タブページ内の各ウィンドウにあるバッファのリスト
let bufnrs = tabpagebuflist(a:tabpagenr)
let winnum = len(bufnrs)
"let mod = len(filter(copy(bufnrs), 'getbufvar(v:val, "&modified")')) ? '+' : ''
let edBufnr = bufnrs[tabpagewinnr(a:tabpagenr) - 1]
"let edBufnr = bufnrs[-1]
let fname = fnamemodify(bufname(edBufnr), ':t')
let fname = fname is '' ? 'NoTitle' : fname
"let tabpagenr = a:tabpagenr > 10 ? 10 : a:tabpagenr-1
"let tabpageNR = ['壱', '弐', '参', '肆', '伍', '陸', '漆', '捌', '玖', '拾', '?'][tabpagenr]
return '%'. a:tabpagenr. 'T'. hiTabLable.
\ a:tabpagenr.
\ repeat(',', winnum). ' '. edBufnr. '-'. fname.
\ '%T%#TabLineFill#'
"\ edBufnr.'-'. fname. '%T%#TabLineFill#'
"\ hiTabLable. '['. a:tabpagenr. '] '.
endfunction "}}}
"=============================================================================
"その他のhighlight
"全角スペースを表示 TODO:aug vimrc_colorschemeに加える "{{{
if has('syntax')
syntax on
aug InvisibleIndicator
au!
au VimEnter,BufEnter * call ActivateInvisibleIndicator()
aug END
endif
function! ActivateInvisibleIndicator()
hi ZenkakuSpace cterm=underline ctermfg=darkgrey gui=underline guifg=darkgrey
" 全角スペースを明示的に表示する。
silent! 2match ZenkakuSpace / /
endfunction
"}}}
"窓にカーソルの痕跡を残す
aug vimrc_CursorTrack
au!
"au WinLeave * match CursorTrack /\%#/
"au WinEnter * match none
aug END
"-----------------------------------------------------------------------------
aug vimrc_colorscheme
au!
au ColorScheme *
\ call <SID>CursorIM() |
\ call <SID>StatusLineNC_fixer() |
\ call <SID>Add_stl8tal_hl() |
\ call <SID>Other_hl()
aug END
"" 日本語入力ON時のカーソルの色を設定
function! s:CursorIM() "{{{
if has('multi_byte_ime') || has('xim')
highlight CursorIM guibg=#ffb700 guifg=NONE
endif
endfunction
"}}}
"StatusLine, TabLine で使うhighlight
function! s:StatusLineNC_fixer() "{{{
"c] StatusLine のhlを取得してguibg guifgを取得
hi StatusLineNC term=reverse cterm=reverse gui=NONE guibg=Gray80 guifg=Black
endfunction
"}}}
function! s:Add_stl8tal_hl() "{{{
hi User9 gui=bold guifg=darkblue guibg=lightcyan
hi User8 gui=bold guifg=darkcyan guibg=lightblue
hi User7 gui=bold guifg=moccasin guibg=hotpink
hi TabLineInfo term=reverse ctermfg=Black ctermbg=LightBlue guifg=black guibg=lightblue
hi ShujuuMaster guibg=indianred3 ctermbg=darkred
hi ShujuuServant guibg=darkslategray4 ctermbg=darkgreen
hi ShujuuSlave guibg=royalblue4 ctermbg=blue
hi User1 guibg=indianred3 ctermbg=darkred
hi User2 guibg=darkslategray4 ctermbg=darkgreen
hi User3 guibg=royalblue4 ctermbg=blue
hi TDD_Red guibg=indianred3 ctermbg=darkred
"exe 'hi '. substitute(substitute(s:__Gs_hi('TabLine'), 'guifg=\S\+\ze\s', 'guifg=magenta', ''), 'TabLine', 'TabLineWinnum', '')
"exe 'hi '. substitute(substitute(s:__Gs_hi('TabLineSel'), 'guifg=\S\+\ze\s', 'guifg=magenta', ''), 'TabLineSel', 'TabLineSelWinnum', '')
endfunction
"}}}
function! s:Other_hl() "{{{
hi Pmenu guifg=white guibg=#6A5CB4 gui=NONE
hi CursorTrack guibg=darkslategray4
endfunction
"}}}
"a:groupnameの:hiを返す
function! s:__Gs_hi(groupname) "{{{
redir => hl
exe 'hi '. a:groupname
redir END
let hl = substitute(hl, '[\r\n]', '', 'g') "改行除く
let hl = substitute(hl, 'xxx', '', '')
return hl
endfunction
"}}}
"=============================================================================
"表示系
"不可視文字表示
se list lcs=
se lcs +=tab:>-
se lcs +=trail:_ "行末空白
se lcs +=extends:> "画面に表示しきれない (続く)
se lcs +=precedes:< "画面に表示しきれない (続く)
se lcs +=eol:$
"隙間を埋める文字
se fillchars=
se fcs +=vert:\|
se fcs +=stl:\
se fcs +=stlnc:\
se fcs +=fold:\
se fcs +=diff:-
let &sbr = '> ' "折り返された行の先頭に表示する文字列
se cpo +=n "'sbr'を行番号の間に表示させる
se guioptions=
"se go +=c "単純な選択にはポップアップダイアログでなくコンソールダイアログを使う
se go +=r "右スクロールバーを常に表示
se go +=L "垂直分割されたとき左スクロールバーを表示
"se go +=m "menubar
se go +=g "無効の menubar 項目を灰色表示
"逐次表示されるメッセージ
se shortmess=
se shm +=a "ステータス省略表現を使用
se shm +=O "読み込み、Quickfix関係のメッセージがその前のメッセージを上書きする
se shm +=T "メッセージが長すぎてコマンドラインに収まらないときは中央を切り詰め
se shm +=W "書き込み時、メッセージを表示しない
se shm +=o "書き込み時のメッセージをその後の読み込みメッセージで上書きする
se shm +=I "Vim開始挨拶メッセージを表示しない
"=============================================================================
"Gvim
"-----------------------------------------------------------------------------
"colorscheme siicEvening
"エラー時の音とビジュアルベルの抑制
au GUIEnter * set vb t_vb=
"Font "{{{
if has('win32')
set gfn=MeiryoKe_Gothic:h8:cSHIFTJIS,\ MS_Gothic:h10:cSHIFTJIS
if hostname() == 'SIICP11ALJ'
set gfn=Migu_1M:h13:cSHIFTJIS,\ MS_Gothic:h14:cSHIFTJIS
endif
if hostname() == 'ATSUTO'
"set gfn=Migu_1M:h15:cSHIFTJIS,\ MS_Gothic:h14:cSHIFTJIS
"set gfn=Migu_1M:h17:cSHIFTJIS,\ MS_Gothic:h14:cSHIFTJIS
set gfn=Migu_1M:h11:cSHIFTJIS,\ MS_Gothic:h10:cSHIFTJIS
endif
"set gfn=Migu_1M:h9:cSHIFTJIS,\ MS_Gothic:h10:cSHIFTJIS
set linespace=2
elseif has('mac')
set guifont=Osaka-等幅:h14
elseif has('xfontset')
set guifontset=a14,r14,k14
set linespace=0
else
endif
"}}}
if filereadable(fnamemodify('~/.privacy/.vimrc_privacy.vim', ':p'))
source ~/.privacy/.vimrc_privacy.vim "lingr.vimのパスワードとか
endif
"=============================================================================
"ファイルタイプ設定
au BufRead,BufNewFile *.markdown,*.md set ft=markdown
autocmd FileType js setlocal ft=javascript
augroup gitcommit
au!
au FileType gitcommit setl nofoldenable tw=60
augroup END
au FileType snippet setl nofoldenable
aug vimrc_help
au!
au FileType help nnoremap <buffer>q <C-w>c
aug END
aug vimrc_vim
au!
au FileType vim
\ inoremap <expr><buffer>\
\ getline('.') =~ '^\s*$' ? "\\\<Space>" : match(getline('.'), '\S')+1 >= col('.') ? "\\\<Space>" : '\'
aug END
aug qf
au!
au FileType qf
\ noremap <buffer> q :cclose<CR>|
\ noremap <buffer> <CR> :.cc<CR>|
\ endif
aug END
"=============================================================================
"Mapping Basis
let mapleader = '\'
let maplocalleader = '_'
noremap [space] <nop>
nmap <Space> [space]
nmap <C-k> [C-k]
nmap <C-g> [C-g]
"-----------------------------------------------------------------------------
"No operation
"インサートモードで間違って出してほしくないキー
nnoremap <F1> <Nop>
noremap <F13> <Nop>
noremap! <F13> <Nop>
noremap <F15> <Nop>
noremap! <F15> <Nop>
noremap <F16> <Nop>
noremap! <F16> <Nop>
inoremap <S-F16> <Nop>
cnoremap <S-F16> <Nop>
inoremap <M-j> <Nop>
"誤爆防止
nnoremap ZZ <Nop>
nnoremap q <Nop>
noremap zq q
noremap z@ @
"勝手なマークを付けさせない
noremap m <Nop>
"-----------------------------------------------------------------------------
"Substitute
noremap ; :
noremap + ;
noremap - ^
noremap S $
nnoremap j gj|nnoremap k gk|vnoremap j gj|vnoremap k gk
call submode#enter_with('gjgk', 'nv', '', 'gj', 'gj')
call submode#enter_with('gjgk', 'nv', '', 'gk', 'gk')
call submode#leave_with('gjgk', 'nv', '', '<Esc>')
call submode#map('gjgk', 'nv', '', 'j', 'gj')
call submode#map('gjgk', 'nv', '', 'k', 'gk')
"nnoremap gj j|nnoremap gk k|vnoremap gj j|vnoremap gk k
nnoremap z<C-l> <C-l>
"-----------------------------------------------------------------------------
"Alternative
"undoフラグはctrlを押しっぱなしでも有効
inoremap <c-g><c-u> <c-g>u
"-----------------------------------------------------------------------------
"Compensation
"; ,
call submode#enter_with('nextChar', 'nv', '', 'z;', ';')
call submode#enter_with('nextChar', 'nv', '', 'z,,', ',')
call submode#leave_with('nextChar', 'nv', '', 'z')
call submode#map('nextChar', 'nv', '', ';', ';')
call submode#map('nextChar', 'nv', '', ',', ',')
noremap z- -
"-----------------------------------------------------------------------------
"インサートモードでの削除コマンドにundoを有効化させる
inoremap <c-h> <c-g>u<c-h>
inoremap <c-u> <c-g>u<c-u>
"inoremap <c-w> <c-g>u<c-w>
"=============================================================================
"Mapping Normal
"-----------------------------------------------------------------------------
"Normal modeで挿入
nnoremap <silent><C-j> :<C-u>call <SID>Insert_CR()<CR>
function! s:Insert_CR() "{{{
let foldclosedend = foldclosedend('.')
if foldclosedend != -1
call append(foldclosedend, '')
else
call append('.', '')
endif
normal j
endfunction "}}}
nnoremap [C-k]<C-j> :i<CR><CR>.<CR>
nnoremap [space]<C-j> :i<CR><CR>.<CR>
"空白を挿入する
nnoremap [space]a a<Space><Esc>
nnoremap <C-Space> a<Space><Esc>
nnoremap [space]i i<Space><Esc>
nnoremap [space]s i<Space><Esc>la<Space><Esc>h
"-----------------------------------------------------------------------------
let s:bind_win = 'm'
"Win/Buf Open/Close"{{{
"nnoremap <silent> [space]K :exe 'h '.expand('<cword>')<CR><C-w>s<C-w>w<C-o><C-w>W
nnoremap [space]K <C-w>}
exe 'nnoremap '. s:bind_win. 's <C-w>s'
exe 'nnoremap '. s:bind_win. 'b <C-w>v'
exe 'nnoremap '. s:bind_win. 'o <C-w>o'
"現在Bufを新しいタブページで開く
nnoremap <silent> <C-w>; :tab split<CR>
exe 'nnoremap <silent> '. s:bind_win. 'v :tab split<CR>'
"ウィンドウレイアウトを保持したままバッファを閉じるコマンド
com! KeepWinBd let kwbd_bn= bufnr("%") |bn |exe "bd ".kwbd_bn |unlet kwbd_bn
nmap dm <SID>bd
noremap <SID>bd :bd<CR>
nmap dn <SID>KeepWinBd
noremap <SID>KeepWinBd :KeepWinBd<CR>
nmap dq <C-w>c
exe 'nnoremap '. s:bind_win. 'q <C-w>c'
exe 'nnoremap '. s:bind_win. 'dd <C-w>c'
nmap <silent>dv <SID>tabc
nmap <silent>dgt <SID>tabc
noremap <SID>tabc :tabc<CR>
"指定した番号の窓を閉じる
nmap ct <SID>Cls_remoteWin1
nmap cz <SID>Cls_remoteWin$
nmap c1 <SID>Cls_remoteWin1
nmap c2 <SID>Cls_remoteWin2
nmap c3 <SID>Cls_remoteWin3
nmap c4 <SID>Cls_remoteWin4
nmap c5 <SID>Cls_remoteWin5
nmap c6 <SID>Cls_remoteWin6
nmap d,t <SID>Cls_remoteWin1
nmap d,z <SID>Cls_remoteWin$
nmap d,1 <SID>Cls_remoteWin1
nmap d,2 <SID>Cls_remoteWin2
nmap d,3 <SID>Cls_remoteWin3
nmap d,4 <SID>Cls_remoteWin4
nmap d,5 <SID>Cls_remoteWin5
nmap d,6 <SID>Cls_remoteWin6
nmap mdt <SID>Cls_remoteWin1
nmap mdz <SID>Cls_remoteWin$
nmap md1 <SID>Cls_remoteWin1
nmap md2 <SID>Cls_remoteWin2
nmap md3 <SID>Cls_remoteWin3
nmap md4 <SID>Cls_remoteWin4
nmap md5 <SID>Cls_remoteWin5
nmap md6 <SID>Cls_remoteWin6
nnoremap <SID>Cls_remoteWin$ :call <SID>Cls_remoteWin(winnr('$'))<CR>
nnoremap <SID>Cls_remoteWin1 :call <SID>Cls_remoteWin(1)<CR>
nnoremap <SID>Cls_remoteWin2 :call <SID>Cls_remoteWin(2)<CR>
nnoremap <SID>Cls_remoteWin3 :call <SID>Cls_remoteWin(3)<CR>
nnoremap <SID>Cls_remoteWin4 :call <SID>Cls_remoteWin(4)<CR>
nnoremap <SID>Cls_remoteWin5 :call <SID>Cls_remoteWin(5)<CR>
nnoremap <SID>Cls_remoteWin6 :call <SID>Cls_remoteWin(6)<CR>
function! s:Cls_remoteWin(winnr) "{{{
let save_winnr = winnr()
exe a:winnr. 'wincmd w'
hide
if save_winnr == a:winnr
return
endif
let save_winnr = s:__Gv_adjust_saveWinnr(save_winnr, [a:winnr])
exe save_winnr. 'wincmd w'
endfunction
"}}}
"特殊窓を遠隔で閉じるコマンド
nmap cq <SID>Close_allSpecialWins
nmap d,q <SID>Close_allSpecialWins
nnoremap <silent><SID>Close_allSpecialWins :call <SID>Close_allSpecialWins({'option': ['&pvw'], 'bt': ['quickfix'], 'ft': ['unite']})<CR>
function! s:Close_allSpecialWins(spclTypes) "{{{
let save_winnr = winnr()
let killedwinnr_list = []
windo call add(killedwinnr_list, s:__chk8kill_SpclWin_winnr(a:spclTypes))
let save_winnr = s:__Gv_adjust_saveWinnr(save_winnr, killedwinnr_list)
exe save_winnr.'wincmd w'
endfunction
"}}}
function! s:__chk8kill_SpclWin_winnr(spclTypes) "{{{
if s:___jg_spclWin(a:spclTypes)
let winnr = winnr()
hide
return winnr
endif
endfunction "}}}
function! s:___jg_spclWin(spclTypes) "{{{
let result = 0
for pcd in a:spclTypes.option
if pcd
return 1
endif
endfor
for pcd in a:spclTypes.bt
if &bt ==# pcd
return 1
endif
endfor
for pcd in a:spclTypes.ft
if &ft ==# pcd
return 1
endif
endfor
endfunction
"}}}
function! s:__Gv_adjust_saveWinnr(save_winnr, killedwinnr_list) "{{{
let save_winnr = a:save_winnr
for killedwinnr in reverse(a:killedwinnr_list)
if killedwinnr == 0