-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path_xvimrc
More file actions
364 lines (337 loc) · 12.2 KB
/
_xvimrc
File metadata and controls
364 lines (337 loc) · 12.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
"-----------------------------------------------------
" ___ ___ ___ ___
" /\__\ ___ /\__\ /\ \ /\ \
" /:/ / /\ \ /::| | /::\ \ /::\ \
" /:/ / \:\ \ /:|:| | /:/\:\ \ /:/\:\ \
" /:/__/ ___ /::\__\ /:/|:|__|__ /::\~\:\ \ /:/ \:\ \
" |:| | /\__\ __/:/\/__/ /:/ |::::\__\ /:/\:\ \:\__\ /:/__/ \:\__\
" |:| |/:/ / /\/:/ / \/__/~~/:/ / \/_|::\/:/ / \:\ \ \/__/
" |:|__/:/ / \::/__/ /:/ / |:|::/ / \:\ \
" \::::/__/ \:\__\ /:/ / |:|\/__/ \:\ \
" ~~~~ \/__/ /:/ / |:| | \:\__\
" \/__/ \|__| \/__/
"
"-----------------------------------------------------
" 基本的な設定
"-----------------------------------------------------
"色設定
" let g:solarized_termcolors=256
" colorscheme solarized
" set background=dark
" colorscheme earendel
" colorscheme nu42dark
" colorscheme jellybeans
" colorscheme inkpot
" colorscheme molokai
" colorscheme hybrid
" colorscheme mydark
set t_Co=256
" viとの互換性をとらない(vimの拡張機能を使うため)
set nocompatible
"行頭の余白内でTabを打ち込むと'shiftwidth'の数だけインデントする
set smarttab
" 改行コードの自動認識
set fileformats=unix,dos,mac
" ビープ音を鳴らさない
set vb t_vb=
" バックスペースで削除できるものを指定
set backspace=indent,eol,start
" 8進数を10進数として扱う
set nrformats-=octal
"ペーストを受け付ける
" set paste
" マウスを使える場合はvim内で使用可能にする
if has("mouse")
set mouse=a
endif
" UTF-8の□や○でカーソル位置がずれないようにする
if exists('&ambiwidth')
set ambiwidth=double
endif
" set wildmode=longest:full,list
set foldmethod=marker
set display=lastline
set pumheight=10
"-----------------------------------------------------
" filetypeのalias
"-----------------------------------------------------
au BufRead,BufNewFile,BufReadPre *coffee set filetype=coffee
au BufRead,BufNewFile,BufReadPre *vimperatorrc set filetype=vim
au BufRead,BufNewFile,BufReadPre *zsh* set filetype=sh
"-----------------------------------------------------
" キーバインド変更
"-----------------------------------------------------
" Leader
let mapleader = ","
" TODOを探す
noremap <Leader>t :noautocmd vimgrep /TODO/j **/*.rb **/*.js **/*.erb **/*.haml<CR>:cw<CR>
" TABにて対応ペアにジャンプ
nnoremap <Tab> %
vnoremap <Tab> %
" vを二回で行末まで選択
vnoremap v $h
" インサートモード
imap <C-e> <C-o>$
" imap <C-a> <Home>
imap <C-a> <C-o>^
" imap <expr> <C-w> (matchstr(getline('.'), '.', col('.')-1) =~ '[^\s\n\t\r\f$]' ? '<C-o>db' : '<C-o>daw')
" imap <C-w> <C-o>db
" imap <C-w> <C-o>db<C-o>x
imap <C-b> <Left>
imap <C-f> <Right>
imap <C-n> <Down>
imap <C-p> <Up>
imap <C-u> <C-u><C-o>d0
imap <C-d> <Del>
imap <expr> <C-k> "\<C-g>u".(col('.') == col('$') ? '<C-o>gJ' : '<C-o>D')
" コマンドモード
cmap <C-b> <Left>
cmap <C-f> <Right>
cmap <C-k> <C-\>e getcmdpos() == 1 ? '' : getcmdline()[:getcmdpos()-2]<CR>
" ノーマルモード
map <C-k> <C-w>p
map <C-l> <C-w>l
map <C-h> <C-w>h
map <C-_> o<ESC>
map E <End>
map J gJ
" ESCを二回押すことでハイライトを消す
nmap <silent> <Esc><Esc> :nohlsearch<CR>
" quickfixでnextとprev
nnoremap [q :cprevious<CR>
nnoremap ]q :cnext<CR>
" nnoremap j gj
" nnoremap k gk
nnoremap <space><space> :<C-u>edit ~/.vimrc<CR>
nnoremap <space>s :<C-u>source ~/.vimrc<CR>
nnoremap <space>p :<C-u>edit ~/.vimrc_plugins<CR>
" 入力モード中に素早くjjと入力した場合はESCとみなす
" 入力モード中に素早く;;と入力した場合はESCとみなす
" inoremap ;; <Esc>
"-----------------------------------------------------
" 検索関係
"-----------------------------------------------------
" コマンド、検索パターンを100個まで履歴に残す
set history=1000
" 検索の時に大文字小文字を区別しない
set ignorecase
" 検索の時に大文字が含まれている場合は区別して検索する
set smartcase
" 最後まで検索したら先頭に戻らない
set nowrapscan
" インクリメンタルサーチを使う
set incsearch
" バックスラッシュやクエスチョンを状況に合わせ自動的にエスケープ
cnoremap <expr> / getcmdtype() == '/' ? '\/' : '/'
cnoremap <expr> ? getcmdtype() == '?' ? '\?' : '?'
" 検索後にジャンプした際に検索単語を画面中央に持ってくる
nnoremap n nzz
nnoremap N Nzz
nnoremap * *zz
nnoremap # #zz
nnoremap g* g*zz
nnoremap g# g#zz
"------------------------------
" マーク関係
" mでマーク `でジャンプ
"------------------------------
if !exists('g:markrement_char')
let g:markrement_char = [
\ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
\ 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
\ ]
endif
nnoremap <silent>m :<C-u>call <SID>AutoMarkrement()<CR>
function! s:AutoMarkrement()
if !exists('b:markrement_pos')
let b:markrement_pos = 0
else
let b:markrement_pos = (b:markrement_pos + 1) % len(g:markrement_char)
endif
execute 'mark' g:markrement_char[b:markrement_pos]
echo 'marked' g:markrement_char[b:markrement_pos]
endfunction
" let g:showmarks_include="abcdefghijklmnopqrstuvwxyz"
" ステータスラインに表示する情報の指定
" set statusline=%n\:%y%F\ \|%{(&fenc!=''?&fenc:&enc).'\|'.&ff.'\|'}%m%r%=%c\:%l/%L:
" ステータスラインの表示
" 参考URL
" http://blog.ruedap.com/entry/20110712/vim_statusline_git_branch_name
set statusline=%< " 行が長すぎるときに切り詰める位置
set statusline+=%n " バッファ番号
set statusline+=%m " %m 修正フラグ
set statusline+=%h " %h ヘルプバッファフラグ
set statusline+=%w " %w プレビューウィンドウフラグ
set statusline+=%y " バッファ内のファイルのタイプ
set statusline+=%F " バッファ内のファイルのフルパス
" if winwidth(0) >= 130
" set statusline+=%F " バッファ内のファイルのフルパス
" else
" set statusline+=%t " ファイル名のみ
" endif
set statusline+=%r " %r 読み込み専用フラグ
set statusline+=\ \|%{(&fenc!=''?&fenc:&enc).'\|'.&ff.'\|'} " fencとffを表示
set statusline+=\ " 空白スペース
set statusline+=%= " 左寄せ項目と右寄せ項目の区切り
set statusline+=%1l " 何行目にカーソルがあるか
set statusline+=/
set statusline+=%L " バッファ内の総行数
set statusline+=,
set statusline+=%c " 何列目にカーソルがあるか
" set statusline+=%V " 画面上の何列目にカーソルがあるか
set statusline+=\ " 空白スペース2個
set statusline+=%{b:charCounterCount}
set statusline+=\|%P\|" ファイル内の何%の位置にあるか
set statusline+=%{fugitive#statusline()} " Gitのブランチ名を表示
" ステータスラインの色
highlight StatusLine term=NONE cterm=NONE ctermfg=black ctermbg=cyan
"-----------------------------------------------------
" タブ・インデント
"-----------------------------------------------------
" タブが対応する空白の数
set tabstop=2
" タブやバックスペースの使用等の編集操作をするときに、タブが対応する空白の数
set softtabstop=2
" インデントの各段階に使われる空白の数
set shiftwidth=2
" タブを挿入するとき、代わりに空白を使う
set expandtab
" インデントをオプションの'shiftwidth'の値の倍数に丸める
set shiftround
" オートインデントを有効にする
set autoindent
" 新しい行を作ったときに高度な自動インデントを行う。 'cindent'
" がオンのときは、'smartindent' をオンにしても効果はない。
set smartindent
"----------------------------------------------------
"" 国際化関係
"----------------------------------------------------
" 文字コードの設定
" fileencodingsの設定ではencodingの値を一番最後に記述する
set encoding=utf-8
"set encoding=japan
set termencoding=utf-8
set fileencoding=utf-8
"----------------------------------------------------
" clipboard
" よくわからない...
"----------------------------------------------------
"
" if has('unnamedplus')
" set clipboard& clipboard+=unnamedplus
" else
" set clipboard& clipboard+=unnamed,autoselect
" endif
if has("clipboard")
vmap ,y "+y
nmap ,p "+gP
" exclude:{pattern} must be last ^= prepend += append
if has("gui_running") || has("xterm_clipboard")
silent! set clipboard^=unnamedplus
set clipboard^=unnamed
endif
endif
"-----------------------------------------------------
" 文字数カウント
"-----------------------------------------------------
" statusbarにファイル中の文字数を表示
if exists("anekos_charCounter")
finish
endif
let anekos_charCounter=1
augroup CharCounter
autocmd!
autocmd BufCreate,BufEnter * call <SID>Initialize()
autocmd BufUnload,FileWritePre,BufWritePre * call <SID>Update()
augroup END
function! s:Initialize()
if exists('b:charCounterCount')
else
return s:Update()
endif
endfunction
function! s:Update()
let b:charCounterCount = s:CharCount()
endfunction
function! s:CharCount()
let l:result = 0
for l:linenum in range(0, line('$'))
let l:line = getline(l:linenum)
let l:result += strlen(substitute(l:line, ".", "x", "g"))
endfor
return l:result
endfunction
function! AnekoS_CharCounter_CharCount()
return s:CharCount()
endfunction
" 選択してccで文字数カウント
vnoremap <silent> cc :s/./&/gn <CR>
"-----------------------------------------------------
" 矩形選択で連番入力
"-----------------------------------------------------
" 数字を選んで co と入力
nnoremap <silent> co :ContinuousNumber <C-a><CR>
vnoremap <silent> co :ContinuousNumber <C-a><CR>
command! -count -nargs=1 ContinuousNumber let c = col('.')|for n in range(1, <count>?<count>-line('.'):1)|exec 'normal! j' . n . <q-args>|call cursor('.', c)|endfor
"-----------------------------------------------------
" プラグイン読み込み
"-----------------------------------------------------
if exists("$HOME/.vimrc_plugins")
source $HOME/.vimrc_plugins
endif
"-----------------------------------------------------
" 文字コードの自動認識
"-----------------------------------------------------
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
set whichwrap=b,s,h,l,<,>,[,]