-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
163 lines (137 loc) · 5.87 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
set nocompatible " be iMproved, required
filetype off " required
filetype plugin indent on " required
set laststatus=2 " 常にステータスラインを表示
set statusline=%<%F\ %r%h%w%y%{'['.(&fenc!=''?&fenc:&enc).']['.&ff.']'}%=%4v(ASCII=%03.3b,HEX=%02.2B)\ %l/%L(%P)%m
set textwidth=0 " 一行に長い文章を書いていても自動折り返しをしない
set nobackup " バックアップ取らない
set noswapfile " スワップファイル作らない
set autoread " 他で書き換えられたら自動で読み直す
set hidden " 編集中でも他のファイルを開けるようにする
set formatoptions=lmoq " テキスト整形オプション,マルチバイト系を追加
set vb t_vb= " ビープをならさない
set browsedir=buffer " Exploreの初期ディレクトリ
set showcmd " コマンドをステータス行に表示
set showmatch " 括弧の対応をハイライト
set showcmd " 入力中のコマンドを表示
set number " 行番号表示
set list " 不可視文字表示
set listchars=tab:>.,trail:_,extends:>,precedes:< " 不可視文字の表示形式
set display=uhex " 印字不可能文字を16進数で表示
set backspace=indent,eol,start
" 全角スペースをハイライト
if has("syntax")
syntax on
function! ActivateInvisibleIndicator()
syntax match InvisibleJISX0208Space " " display containedin=ALL
highlight InvisibleJISX0208Space term=underline ctermbg=Cyan guibg=Cyan
endf
augroup invisible
autocmd! invisible
autocmd BufNew,BufRead * call ActivateInvisibleIndicator()
augroup END
endif
" カレントウィンドウにのみ罫線を引く
augroup cch
autocmd! cch
autocmd WinLeave * set nocursorline
autocmd WinEnter,BufRead * set cursorline
augroup END
" インデントの設定
set autoindent
set smartindent
set tabstop=2 shiftwidth=2 softtabstop=2
set expandtab
function SetForGolangAndC()
setlocal listchars=tab:\ \ ,trail:_,extends:>,precedes:<
setlocal noexpandtab
endfunction
augroup vimrc
autocmd! FileType go call SetForGolangAndC()
autocmd! FileType c call SetForGolangAndC()
autocmd! FileType perl setlocal shiftwidth=4 tabstop=4 softtabstop=4
autocmd! FileType html setlocal shiftwidth=2 tabstop=2 softtabstop=2
autocmd! FileType css setlocal shiftwidth=2 tabstop=2 softtabstop=2
augroup END
set wildmenu " コマンド補完時に現在の候補をハイライト
set wildchar=<tab> " コマンド補完を開始するキーをtabキーに割り当て(デフォルトでtabキーに割り当てられてる)
set history=1000 " コマンド・検索パターンの履歴数
" 検索の設定
set wrapscan " 最後まで検索したら先頭へ戻る
set ignorecase " 大文字小文字無視
set smartcase " 大文字ではじめたら大文字小文字無視しない
set incsearch " インクリメンタルサーチ
set hlsearch " 検索文字をハイライト
" エンコーディング
" 改行文字
set ffs=unix,dos,mac
" デフォルトエンコーディング
set encoding=utf-8
"BufferExploreをキーバインドに割り当て
nmap <silent> <C-k><C-l> :BufExplorer<CR>
"BufferExploreでNo Nameバッファを表示する
let g:bufExplorerShowNoName=1
" カーソル以下の文字列をハイライト
nnoremap <silent> <C-k><C-w> :let @/='\<<C-R>=expand("<cword>")<CR>\>'<CR>:set hls<CR>
" 改行コードの自動認識
set fileformats=unix,dos,mac
" 全角の記号が半角幅にならないようにする
if exists('&ambiwidth')
set ambiwidth=double
endif
" 拡張子の設定
au BufRead,BufNewFile *.t set filetype=perl " perlのテストファイル
au BufRead,BufNewFile *.tx set filetype=html " perlのテンプレートエンジン
"行末にあるスペースを赤字でハイライト
augroup HighlightTrailingSpaces
autocmd!
autocmd VimEnter,WinEnter,ColorScheme * highlight TrailingSpaces term=underline guibg=Red ctermbg=Red
autocmd VimEnter,WinEnter * match TrailingSpaces /\s\+$/
augroup END
"アルファベットをインクリメント
set nf=alpha
" :Eのバグ修正
command E Ex
" matchit.vimを有効(rubyのdo endを%でジャンプ)
source $VIMRUNTIME/macros/matchit.vim
command -nargs=+ GitGrep call GitGrep(<f-args>)
function GitGrep(...)
if a:0 == 1
execute("vim " . a:1 . " `git ls-files .`" . " | cw")
else
execute("vim " . a:1 . " `git ls-files " . a:2 . "`" . " | cw")
end
endfunction!
command -nargs=0 Ref call Ref()
function Ref()
echo ":!command コマンド実行"
echo ":!command % カレントバッファのファイルでコマンド実行"
echo ":r !command コマンド実行してカレント行の直下に書き込み"
echo ":w !command コマンド実行して結果をコマンドラインのバッファに出力"
echo ":'<,'> !command 指定した範囲を標準入力としてコマンドを実行して指定した範囲に書き込み(filter)"
echo "ctrl + r レジスタ番号 挿入モードとExモードでレジスタの内容をペースト. :!と組み合わせるとカレント行を実行できる"
echo "ctrl + a インクリメント"
echo "ctrl + x デクリメント"
echo "矩形選択で g ctrl + a 各行でインクリメント"
echo "矩形選択で g ctrl + x 各行でデクリメント"
echo ":enew No Nameバッファを作成"
echo ":new Windowを分割してNo Nameバッファを作成"
endfunction
" 色をmac vimに合わせる
set background=dark
" mouse操作を無効化
set mouse=
" Load settings for each location.
augroup vimrc-local
autocmd!
autocmd BufNewFile,BufReadPost * call s:vimrc_local(expand('<afile>:p:h'))
augroup END
function! s:vimrc_local(loc)
let files = findfile('.vimrc.local', escape(a:loc, ' ') . ';', -1)
for i in reverse(filter(files, 'filereadable(v:val)'))
source `=i`
endfor
endfunction
"ctagsでデフォルトでジャンプできる候補を表示
" nnoremap <C-]> g<C-]>
nnoremap <silent> <C-]> :TagExplorerExact<CR>