-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc_ubuntu.txt
363 lines (298 loc) · 10.4 KB
/
vimrc_ubuntu.txt
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
highlight LineNr ctermfg=grey
highlight NonText ctermfg=darkgrey
highlight Folded ctermfg=blue
highlight SpecialKey cterm=underline ctermfg=darkgrey
" タブ幅
set ts=2 sw=2
set softtabstop=2
"set noexpandtab
set expandtab
" 行番号
set number
set ignorecase
set smartcase
" 下線表示
set cursorline
" 自動インデント(しない)
set noautoindent
set nocindent
" 対応する括弧をフラッシュ(しない)
"set noshowmatch
set showmatch
" コマンド表示
set showcmd
" ステータス行追加
set laststatus=2
" ステータス行に文字コードと改行コード表示
set statusline=%<%f\ %m%r%h%w%{'['.(&fenc!=''?&fenc:&enc).']['.&ff.']'}%=%l,%c%V%8P
" 前回参照行
autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal g`\"" | endif
" 検索語を画面中央に
nmap n nzz
nmap N Nzz
" 検索結果文字列をハイライト
set hlsearch
" シンタックスハイライト有効
syntax on
" 折り返し無効
set nowrap
set tags=./tags,tags
set grepformat=%f:%l:%m,%f:%l%m,%f\ \ %l%m,%f
set grepprg=grep\ -nh
" neocomplcacheを起動時に有効化
let g:neocomplcache_enable_at_startup = 1
" let g:neocomplcache_enable_quick_match = 1
" 文字コードの自動認識
if &encoding !=# 'utf-8'
set encoding=japan
set fileencoding=japan
endif
if has('iconv')
let s:enc_euc = 'euc-jp'
let s:enc_jis = 'iso-2022-jp'
" iconvがeucJP-msに対応しているかをチェック
if iconv("\x87\x64\x87\x6a", 'cp932', 'eucjp-ms') ==# "\xad\xc5\xad\xcb"
let s:enc_euc = 'eucjp-ms'
let s:enc_jis = 'iso-2022-jp-3'
" iconvがJISX0213に対応しているかをチェック
elseif iconv("\x87\x64\x87\x6a", 'cp932', 'euc-jisx0213') ==# "\xad\xc5\xad\xcb"
let s:enc_euc = 'euc-jisx0213'
let s:enc_jis = 'iso-2022-jp-3'
endif
" fileencodingsを構築
if &encoding ==# 'utf-8'
let s:fileencodings_default = &fileencodings
let &fileencodings = s:enc_jis .','. s:enc_euc .',cp932'
let &fileencodings = &fileencodings .','. s:fileencodings_default
unlet s:fileencodings_default
else
let &fileencodings = &fileencodings .','. s:enc_jis
set fileencodings+=utf-8,ucs-2le,ucs-2
if &encoding =~# '^\(euc-jp\|euc-jisx0213\|eucjp-ms\)$'
set fileencodings+=cp932
set fileencodings-=euc-jp
set fileencodings-=euc-jisx0213
set fileencodings-=eucjp-ms
let &encoding = s:enc_euc
let &fileencoding = s:enc_euc
else
let &fileencodings = &fileencodings .','. s:enc_euc
endif
endif
" 定数を処分
unlet s:enc_euc
unlet s:enc_jis
endif
" 日本語を含まない場合は fileencoding に encoding を使うようにする
if has('autocmd')
function! AU_ReCheck_FENC()
if &fileencoding =~# 'iso-2022-jp' && search("[^\x01-\x7e]", 'n') == 0
let &fileencoding=&encoding
endif
endfunction
autocmd BufReadPost * call AU_ReCheck_FENC()
endif
" 改行コードの自動認識
set fileformats=unix,dos,mac
" □とか○の文字があってもカーソル位置がずれないようにする
if exists('&ambiwidth')
set ambiwidth=double
endif
" project.vimのプロジェクトを素早く開閉する
" ファイルが選択されたら、ウィンドウを閉じる
:let g:proj_flags = "imstc"
" <Leader>Pで、プロジェクトをトグルで開閉する
:nmap <silent> <Leader>P <Plug>ToggleProject
" <Leader>pで、デフォルトのプロジェクトを開く
:nmap <silent> <Leader>p :Project<CR>
autocmd BufAdd .vimprojects silent! %foldopen!
:set helplang=ja
" vimgrepで検索後、QuickFixウィンドウを開く
augroup grepopen
autocmd!
autocmd QuickfixCmdPost vimgrep cw
augroup END
" <C-j>で裏バッファへ切り替える設定例
nnoremap <C-j> <C-^>
" buftabsのオプション設定例
" ファイル名だけ表示
let buftabs_only_basename = 1
" ステータスラインに表示
let buftabs_in_statusline = 1
" Leaderをスペースに変更
let mapleader=" "
" editexisting.vimプラグインを読み込む設定
packadd! editexisting
"不可視文字の可視化
set list listchars=tab:>-,trail:_
" 全角スペース をハイライトする設定
scriptencoding utf-8
augroup highlightIdegraphicSpace
autocmd!
autocmd ColorScheme * highlight IdeographicSpace term=underline ctermbg=DarkGreen guibg=DarkGreen
autocmd VimEnter,WinEnter * match IdeographicSpace / /
augroup END
colorscheme default
" YankRing.vimの履歴ファイルの保存先を変更する
let g:yankring_history_dir = expand('$HOME')
let g:yankring_history_file = '.yankring_history'
" YRShowコマンドを使いやすくする
nnoremap <silent> <F7> :YRShow<CR>
let g:yankring_max_history = 10
let g:yankring_window_height = 13
" 矩形ビジュアルモードで文字の無いところにもカーソルを移動する
set virtualedit=block
" Alignプラグインの設定
let g:Align_xstrlen = 3 " for japanese string
let g:DrChipTopLvlMenu = '' " for 'DrChip' menu
inoremap <expr> = smartchr#loop(' = ', '=', ' == ', ' === ')
inoremap <expr> , smartchr#one_of(', ', ',')
cnoremap <expr> / smartchr#loop('/', '~/', '//', {'ctype': ':'})
autocmd FileType c,cpp inoremap <buffer> <expr> . smartchr#loop('.', '->', '...')
" Control + w のウィンドウ関連
nnoremap ss <C-W>s
nnoremap sc <C-W>c
nnoremap so <C-W>o
nnoremap sj <C-W>j
nnoremap sk <C-W>k
nnoremap <silent> sh <C-W>h:call <SID>good_width()<CR>
nnoremap <silent> sl <C-W>l:call <SID>good_width()<Cr>
" ウィンドウの幅をいい感じにする
function! s:good_width()
if winwidth(0) < 84
vertical resize 84
endif
endfunction
nnoremap + <C-W>+
nnoremap - <C-W>-
" ウィンドウの横幅を大きくする/小さくする
nnoremap ) <C-W>>
nnoremap ( <C-W><LT>
" ウィンドウの大きさを最大化する
function! s:big()
wincmd _ | wincmd |
endfunction
nnoremap <silent> s<CR> :<C-u>call <SID>big()<CR> " 最大化
nnoremap s0 1<C-W>_ " 最小化
nnoremap s. <C-W>= " 全部同じ大きさにする
set nocompatible
filetype plugin indent off
"dein Scripts-----------------------------
if &compatible
set nocompatible " Be iMproved
endif
" Required:
set runtimepath^=~/.vim/dein/repos/github.com/Shougo/dein.vim
" Required:
call dein#begin(expand('~/.vim/dein'))
" Let dein manage dein
" Required:
call dein#add('Shougo/dein.vim')
" Add or remove your plugins here:
call dein#add('Shougo/unite.vim')
call dein#add('Shougo/neosnippet.vim')
call dein#add('Shougo/neosnippet-snippets')
" You can specify revision/branch/tag.
call dein#add('Shougo/vimshell', { 'rev': '3787e5' })
call dein#add('Shougo/vimproc', { 'build': 'make' })
call dein#add('Shougo/neomru.vim')
call dein#add('Shougo/vimfiler.vim')
call dein#add('kana/vim-smartchr')
call dein#add('jlanzarotta/bufexplorer')
call dein#add('posva/vim-vue')
" Required:
call dein#end()
" Required:
filetype plugin indent on
" If you want to install not installed plugins on startup.
"if dein#check_install()
" call dein#install()
"endif
"End dein Scripts-------------------------
"unite prefix key.
nnoremap [unite] <Nop>
nmap <Space>f [unite]
let g:unite_enable_start_insert = 1
" For ag.
if executable('ag')
let g:unite_source_grep_command = 'ag'
let g:unite_source_grep_default_opts = '--nogroup --nocolor --column'
let g:unite_source_grep_recursive_opt = ''
endif
"let g:ackprg="ack-grep -H --nocolor --nogroup --column"
"file_mruの表示フォーマットを指定。空にすると表示スピードが高速化される
let g:unite_source_file_mru_filename_format = ''
nnoremap <silent> ss :<C-u>Unite -buffer-name=files buffer_tab file_rec file file_mru<CR>
nnoremap <silent> sg :<C-u>Unite grep -no-quit<CR>
nnoremap <silent> <C-h> :<C-u>Unite -start-insert help<CR>
nnoremap <silent> <C-t><C-t> :<C-u>Unite -immediately tab:no-current<CR>
autocmd FileType unite call s:unite_my_settings()
function! s:unite_my_settings()
nmap <buffer> <ESC> <Plug>(unite_exit)
imap <buffer> jj <Plug>(unite_insert_leave)
"imap <buffer> <C-w> <Plug>(unite_delete_backward_path)
"sでsplit
nnoremap <silent><buffer><expr> s unite#smart_map('s', unite#do_action('split'))
inoremap <silent><buffer><expr> s unite#smart_map('s', unite#do_action('split'))
"vでvsplit
nnoremap <silent><buffer><expr> v unite#smart_map('v', unite#do_action('vsplit'))
inoremap <silent><buffer><expr> v unite#smart_map('v', unite#do_action('vsplit'))
"fでvimfiler
nnoremap <silent><buffer><expr> f unite#smart_map('f', unite#do_action('vimfiler'))
inoremap <silent><buffer><expr> f unite#smart_map('f', unite#do_action('vimfiler'))
endfunction
"vimデフォルトのエクスプローラをvimfilerで置き換える
let g:vimfiler_as_default_explorer = 1
"セーフモードを無効にした状態で起動する
let g:vimfiler_safe_mode_by_default = 0
"現在開いているバッファのディレクトリを開く
nnoremap <silent> <Leader>fe :<C-u>VimFilerBufferDir -quit<CR>
"現在開いているバッファをIDE風に開く
nnoremap <silent> <Leader>fi :<C-u>VimFilerBufferDir -split -simple -winwidth=35 -no-quit<CR>
"Anywhere SID.
function! s:SID_PREFIX()
return matchstr(expand('<sfile>'), '<SNR>\d\+_\zeSID_PREFIX$')
endfunction
" Set tabline.
function! s:my_tabline() "{{{
let s = ''
for i in range(1, tabpagenr('$'))
let bufnrs = tabpagebuflist(i)
let bufnr = bufnrs[tabpagewinnr(i) - 1] " first window, first appears
let no = i " display 0-origin tabpagenr.
let mod = getbufvar(bufnr, '&modified') ? '!' : ' '
let title = fnamemodify(bufname(bufnr), ':t')
let title = '[' . title . ']'
let s .= '%'.i.'T'
let s .= '%#' . (i == tabpagenr() ? 'TabLineSel' : 'TabLine') . '#'
let s .= no . ':' . title
let s .= mod
let s .= '%#TabLineFill# '
endfor
let s .= '%#TabLineFill#%T%=%#TabLine#'
return s
endfunction "}}}
let &tabline = '%!'. s:SID_PREFIX() . 'my_tabline()'
set showtabline=2 " 常にタブラインを表示
" The prefix key.
nnoremap [Tag] <Nop>
nmap t [Tag]
" Tab jump
for n in range(1, 9)
execute 'nnoremap <silent> [Tag]'.n ':<C-u>tabnext'.n.'<CR>'
endfor
" t1 で1番左のタブ、t2 で1番左から2番目のタブにジャンプ
map <silent> [Tag]c :tablast <bar> tabnew<CR>
" tc 新しいタブを一番右に作る
map <silent> [Tag]x :tabclose<CR>
" tx タブを閉じる
map <silent> [Tag]n :tabnext<CR>
" tn 次のタブ
map <silent> [Tag]p :tabprevious<CR>
" tp 前のタブ
" very magic
nnoremap / /\v
set columns=110
set lines=35
autocmd FileType vue syntax sync fromstart
autocmd FileType * setlocal formatoptions-=ro