-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdot_vimrc
More file actions
492 lines (391 loc) · 14.2 KB
/
dot_vimrc
File metadata and controls
492 lines (391 loc) · 14.2 KB
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
filetype off
if has('vim_starting')
set encoding=utf8
endif
if &compatible
set nocompatible
endif
set runtimepath+=~/.cache/dein/repos/github.com/Shougo/dein.vim
if dein#load_state('~/.cache/dein')
call dein#begin('~/.cache/dein')
" Let dein manage dein
" Required:
call dein#add('~/.cache/dein/repos/github.com/Shougo/dein.vim')
call dein#add('w0ng/vim-hybrid')
call dein#add('bling/vim-airline')
call dein#add('scrooloose/syntastic')
call dein#add('thinca/vim-quickrun')
call dein#add('tyru/open-browser.vim')
call dein#add('vim-jp/vimdoc-ja.git')
call dein#add('godlygeek/tabular')
call dein#add('scrooloose/nerdcommenter')
call dein#add('vim-scripts/gtags.vim')
call dein#add('easymotion/vim-easymotion')
" Required:
call dein#end()
call dein#save_state()
endif
if dein#check_install()
call dein#install()
endif
filetype plugin indent on
syntax enable
let s:is_gui = has('gui_running')
" Basic
let mapleader = ',' " キーマップリーダー
set scrolloff=5 " カーソルの上または下に表示する最小限の行数
set nowrap " 行の折り返しはしない
set textwidth=0 " 入力されているテキストの最大幅 「0」で無効
set backup
set backupdir=~/.vim/tmp
"set nobackup " バックアップの作成は行わない
"set nowritebackup
set swapfile
set directory=~/.vim/tmp
"set noswapfile " スワップファイルの作成は行わない
set autoread " Vimの外部で変更されたことが判明したとき、自動的に読み直す
set hidden " 保存しないで他のファイルを表示することが出来るようにする
set backspace=indent,eol,start " バックスペースでインデントや改行を削除できるようにする
set formatoptions=lmoq " 自動整形の実行方法
set novisualbell " ビープ音 ビジュアルベル制御
set noerrorbells
set vb t_vb=
set noequalalways " ウィンドウサイズの自動調整を無効にする
autocmd FileType * setlocal formatoptions-=ro " 改行後の自動コメントアウト禁止
set ttyfast " 高速ターミナル接続
set browsedir=buffer " ファイルブラウザの初期ディレクトリ
set whichwrap=b,s,<,>,[,],~ " 特定のキーに行頭および行末の回りこみ移動を許可する設定
set showcmd " コマンド (の一部) を画面の最下行に表示する
set ruler " カーソルが何行目の何列目に置かれているかを表示する
set rulerformat=%l,%v
set laststatus=2 " ステータス行を常に表示する
set statusline=%<%f\ #%n%m%r%h%w%{'['.(&fenc!=''?&fenc:&enc).']['.&ff.']'}%y%=%l,%c%V%8P
set cmdheight=3 " コマンドラインに使われる画面上の行数
set showmode " 現在のモードの表示
set nomodeline " モードラインの無効化
set modelines=0
set clipboard+=unnamed " OSのクリップボードを使用
" Vimを終了しても undo 履歴を復元する Vim >= 7.3 {{{
" http://vim-users.jp/2010/07/hack162/
if has('persistent_undo')
set undodir=./.vimundo,~/.vimundo
augroup vimrc-undofile
autocmd!
autocmd BufReadPre ~/* setlocal undofile
augroup END
endif
" }}}
set fileformats=unix,mac,dos
set ambiwidth=double
set list " 不可視文字の表示
set listchars=tab:▸\ ,eol:¬
set mouse=a " マウスの有効化
set guioptions+=a
if !has('nvim')
set ttymouse=xterm2
endif
set helplang=ja " helpを日本語優先に
set shellslash
set autoindent " 新しい行を開始したときに、新しい行のインデントを現在行と同じ量にする
set smartindent " 新しい行を作ったときに高度な自動インデントを行う
set tabstop=4 " <Tab> が対応する空白の数。
set softtabstop=4 " <Tab> の挿入や <BS> の使用等の編集操作をするときに、<Tab> が対応する空白の数。
set shiftwidth=4 " インデントの各段階に使われる空白の数
set expandtab " Insertモードで <Tab> を挿入するのに、適切な数の空白を使う
set smarttab " 行頭の余白内で Tab を打ち込むと、'shiftwidth' の数だけインデントする
set relativenumber
set number " 行番号を表示する。
set showmatch " 対応する括弧をハイライト
set matchtime=1
set timeout timeoutlen=1000 ttimeoutlen=50 "マッピング待ち時間設定
" タイトル設定
set title
let &titlestring = hostname() . " [ Vim ( " . expand("%:t") . " ) ]"
if &term == "screen"
set t_ts=^[k
set t_fs=^[\
endif
if &term == "screen" || &term == "xterm"
set title
endif
autocmd BufWritePre * :%s/\s\+$//e " 保存時に行末の空白を除去する
" 英数字以外を全て制御文字と認識
"nnoremap / /\v
"vnoremap / /\v
set wrapscan " 循環検索
set hlsearch " 検索文字をハイライト
set incsearch " 検索コマンドを打ち込んでいる間にも、打ち込んだところまでのパターンがマッチするテキストを、すぐに表示する
set ignorecase " 検索時に大文字小文字を無視
set smartcase " 大文字小文字の両方が含まれている場合は大文字小文字を区別
nnoremap <ESC><ESC> :nohlsearch<CR> " ハイライト解除
set inccommand=split
set wildmenu "補完候補を表示する
set completeopt=menuone "補完ウィンドウの設定
set wildmode=list:longest,full " 補完モード
set nrformats=
if has('path_extra')
set tags+=tags;
endif
set t_Co=256
syntax enable
let g:neodark#use_256color = 1
set background=dark
colorscheme hybrid
" --------------------------------------------------------------------------
" key binding: {{{
"
nnoremap ; :
" カーソル行を封印
nnoremap <UP> <Nop>
nnoremap <DOWN> <Nop>
nnoremap <LEFT> <Nop>
nnoremap <RIGHT> <Nop>
inoremap <UP> <Nop>
inoremap <DOWN> <Nop>
inoremap <LEFT> <Nop>
inoremap <RIGHT> <Nop>
" カーソルを表示行で移動
nnoremap j gj
nnoremap k gk
" 移動範囲拡大
nnoremap <C-e> 3<C-e>
nnoremap <C-y> 3<C-y>
" 画面分割時の移動
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" 検索結果を画面中央に表示
nnoremap * *zz
nnoremap # #zz
nnoremap n nzz
nnoremap N Nzz
" Quick tab creation and navigation.
nnoremap <leader>tn :tabnew<CR>
nnoremap <leader>tm :tabmove
nnoremap <leader>te :tabedit
" move tabs
nnoremap tl gt
nnoremap th gT
" ノーマルモード時でも改行を有効に
nnoremap <CR> o<ESC>
" カンマの後に自動的にスペースを追加
inoremap , ,<Space>
" 全選択
nnoremap <Leader>a ggVG
" 縦に分割し、分割したスクリーンをアクティブに
nnoremap <leader>w <C-w>v<C-w>l
" help設定
" via https://github.com/linyows/.vim/blob/master/.vimrc
" nnoremap <C-i> :<C-u>help<Space>
nnoremap <C-h><C-h> :<C-u>help<Space><C-r><C-w><Enter>
" vimrcの編集
nnoremap <leader>ev <C-w><C-v><C-l>:e $MYVIMRC<CR>
" vimrcの反映
nnoremap <leader>rv :source $MYVIMRC<CR>
" }}}
" --------------------------------------------------------------------------
" 全角スペースのハイライト化 {{{
"
function! ZenkakuSpace()
highlight ZenkakuSpace cterm=reverse ctermfg=DarkMagenta gui=reverse guifg=DarkMagenta
endfunction
if has('syntax')
augroup ZenkakuSpace
autocmd!
" ZenkakuSpaceをカラーファイルで設定するなら次の行は削除
autocmd ColorScheme * call ZenkakuSpace()
" 全角スペースのハイライト指定
autocmd VimEnter,WinEnter * match ZenkakuSpace / /
augroup END
call ZenkakuSpace()
endif
" }}}
" --------------------------------------------------------------------------
" カレント行、列に罫線を引く {{{
"
augroup cch
autocmd! cch
autocmd WinLeave * set nocursorline
autocmd WinLeave * set nocursorcolumn
autocmd WinEnter,BufRead * set cursorline
autocmd WinEnter,BufRead * set cursorcolumn
augroup END
" }}}
" --------------------------------------------------------------------------
" 編集ファイルのカレントディレクトリを自動的に移動 {{{
" from Vimテクニックバイブル
"
augroup grlcd
autocmd!
autocmd BufEnter * lcd %:p:h
augroup END
" }}}
" --------------------------------------------------------------------------
" ペーストしたテキストをビジュアルモードで再選択: {{{
" from Vimテクニックバイブル
"
nnoremap <expr> gp '`[' . strpart(getregtype(), 0, 1) . '`]'
" }}}
" --------------------------------------------------------------------------
" Restore cursor position upon reopening files: {{{
" カーソル位置の復元
"
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
" }}}
" --------------------------------------------------------------------------
" ペーストモードの切り替え {{{
"
let paste_mode = 0
function! Paste_on_off()
if g:paste_mode == 0
set paste
let g:paste_mode = 1
else
set nopaste
let g:paste_mode = 0
endif
return
endfunction
" }}}
nnoremap <F8> :call Paste_on_off()<CR>
set pastetoggle=<F8>
" }}}
" --------------------------------------------------------------------------
" memolist: {{{
"
map <Leader>mn :MemoNew<CR>
map <Leader>ml :MemoList<CR>
map <Leader>mg :MemoGrep<CR>
let g:memolist_path = "~/Dropbox/document"
"}}}
" --------------------------------------------------------------------------
" NERDCommenter: {{{
"
let g:NERDCreateDefaultMappings = 0
let NERDSpaceDelims = 1
nmap <Leader>/ <Plug>NERDCommenterToggle
vmap <Leader>/ <Plug>NERDCommenterToggle
nmap <Leader>/a <Plug>NERDCommenterAppend
" }}}
" --------------------------------------------------------------------------
" insert-statusline: {{{
" 挿入モード時の色指定
" https://github.com/fuenor/vim-statusline/blob/master/insert-statusline.vim
"
if !exists('g:hi_insert')
let g:hi_insert = 'highlight StatusLine guifg=White guibg=DarkCyan gui=none ctermfg=White ctermbg=DarkCyan cterm=none'
endif
if has('unix') && !has('gui_running')
inoremap <silent> <ESC> <ESC>
inoremap <silent> <C-[> <ESC>
endif
if has('syntax')
augroup InsertHook
autocmd!
autocmd InsertEnter * call s:StatusLine('Enter')
autocmd InsertLeave * call s:StatusLine('Leave')
augroup END
endif
let s:slhlcmd = ''
function! s:StatusLine(mode)
if a:mode == 'Enter'
silent! let s:slhlcmd = 'highlight ' . s:GetHighlight('StatusLine')
silent exec g:hi_insert
else
highlight clear StatusLine
silent exec s:slhlcmd
endif
endfunction
function! s:GetHighlight(hi)
redir => hl
exec 'highlight '.a:hi
redir END
let hl = substitute(hl, '[\r\n]', '', 'g')
let hl = substitute(hl, 'xxx', '', '')
return hl
endfunction
" }}}
" --------------------------------------------------------------------------
" syntastic: {{{
"
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_check_on_open = 1
let g:syntastic_error_symbol='✗'
let g:syntastic_warning_symbol='⚠'
let g:syntastic_enable_balloons = 0
let g:syntastic_enable_highlighting = 1
let g:syntastic_auto_jump = 0
let g:syntastic_loc_list_height = 5
let g:syntastic_phpcs_disable = 0
let g:syntastic_mode_map = { 'mode': 'active',
\ 'active_filetypes': ['html', 'javascript', 'php'],
\ 'passive_filetypes': [] }
let g:syntastic_stl_format = '[%E{Err: %fe #%e}%B{, }%W{Warn: %fw #%w}]'
" }}}
" --------------------------------------------------------------------------
" smartword: {{{
"
"nmap w <Plug>(smartword-w)
"nmap b <Plug>(smartword-b)
"nmap ge <Plug>(smartword-ge)
"xmap w <Plug>(smartword-w)
"xmap b <Plug>(smartword-b)
"xmap e <Plug>(smartword-e)
" }}}
" --------------------------------------------------------------------------
" easy motion: {{{
"
"
let g:EasyMotion_leader_key = '<Leader>'
" }}}
" --------------------------------------------------------------------------
" Tabularize {{{
"
nmap <Leader>a= :Tabularize /=<CR>
vmap <Leader>a= :Tabularize /=<CR>
nmap <Leader>a== :Tabularize /=><CR>
vmap <Leader>a== :Tabularize /=><CR>
nmap <Leader>a: :Tabularize /:\zs<CR>
vmap <Leader>a: :Tabularize /:\zs<CR>
" }}}
" --------------------------------------------------------------------------
" open-browser.vim: {{{
"
let g:netrw_nogx = 1
nmap gx <Plug>(openbrowser-smart-search)
vmap gx <Plug>(openbrowser-smart-search)
" }}}
" --------------------------------------------------------------------------
" gtags:"{{{
" requier brew install global
" 検索結果Windowを閉じる
nmap <C-q> <C-w><C-w><C-w>q
" Grep 準備
nmap <C-g> :Gtags -g
" このファイルの関数一覧
nmap <C-l> :Gtags -f %<CR>
" カーソル以下の定義元を探す
nmap <C-i> :Gtags <C-r><C-w><CR>
" カーソル以下の使用箇所を探す
nmap <C-@> :Gtags -r <C-r><C-w><CR>
" 次の検索結果
nmap <C-n> :cn<CR>
" 前の検索結果
nmap <C-p> :cp<CR>
" }}}
" --------------------------------------------------------------------------
" quickrun:"{{{
let g:quickrun_config = {}
let g:quickrun_config.markdown = {
\ 'outputter' : 'null',
\ 'command' : 'open',
\ 'cmdopt' : '-a',
\ 'args' : 'Marked',
\ 'exec' : '%c %o %a %s',
\ }