-
Notifications
You must be signed in to change notification settings - Fork 1
/
myvimrc
119 lines (105 loc) · 3.63 KB
/
myvimrc
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
"=== encoding
set enc=utf-8
set fencs=ucs-bom,iso-2022-jp,euc-jp,sjis,cp932,utf-8
set fileformats=unix,dos,mac
" FROM <http://www.kawaz.jp/pukiwiki/?vim>
" if fenc is iso-2022-jp and buffer is ascii only then change fenc as enc
" if this failed, do :e ++enc=utf-8
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
"=== for sudo vim cursorkey
set nocompatible
"=== status line
set laststatus=2
set statusline=%<%F%h%m%r\ [%Y][%{&ff}][%{&fenc!=''?&fenc:&enc}:0x\%02.6B]%=%l,%c%V\ %P
"=== syntax
" check /usr/share/vim/vim74/filetype.vim
au BufNewFile,BufRead *.ssi setf perl
syntax on
filetype on
autocmd FileType c,cpp,perl,javascript,SH set cindent tabstop=4 shiftwidth=4
autocmd FileType MARKDOWN set shiftwidth=4 expandtab smarttab
let g:is_bash = 1
"=== cursor
" FROM <http://qiita.com/usamik26/items/f733add9ca910f6c5784>
" style swith I / BOX
let &t_ti.="\e[1 q"
let &t_SI.="\e[5 q" " Insert: I
let &t_SR.="\e[3 q" " Replace: _
let &t_EI.="\e[1 q" " Normal: []
let &t_te.="\e[0 q"
"=== IME
" FROM <https://chanko.hatenadiary.jp/entry/2016/10/28/162648>
" IME OFF when Insert/Replace/Normal
let &t_SI.="\e[<0t"
let &t_SR.="\e[<0t"
let &t_EI.="\e[<0t"
"=== mouse
set mouse=a
set ttymouse=sgr
"=== color
" default colorscheme are here: /usr/share/vim/vim74/colors/
" user installed are here: ~/.vim/colors/
set background=dark
"set termguicolors
"colorscheme evening
"colorscheme elflord
"colorscheme molokai
"colorscheme solarized
"=== insert/normal mode
set cursorline
augroup InsertHook
autocmd!
" colorscheme によっては、適切な色ではない.
" vimrc_local側でcolorschemeに応じて調整が必要.
autocmd InsertEnter * hi StatusLine ctermbg=cyan guibg=cyan
autocmd InsertLeave * hi StatusLine ctermbg=white guibg=white
autocmd InsertEnter * hi CursorLine cterm=bold gui=bold guibg=darkcyan
autocmd InsertLeave * hi CursorLine cterm=NONE gui=NONE guibg=gray40
augroup END:
"=== search
" FROM <https://qiita.com/nrk_baby/items/154e3fa15c48a39e3375#%E3%82%B4%E3%83%BC%E3%83%AB>
" 小文字の検索でも大文字も見つかるようにする
set ignorecase
" ただし大文字も含めた検索の場合はその通りに検索する
set smartcase
" インクリメンタルサーチを行う
set incsearch
" 検索結果をハイライト表示
set hlsearch
"=== keybind
" FROM <https://qiita.com/nrk_baby/items/154e3fa15c48a39e3375#%E3%82%B4%E3%83%BC%E3%83%AB>
" 入力モード中に素早くjjと入力した場合はESCとみなす
inoremap jj <Esc>
" vを二回で行末まで選択
vnoremap v $h
" ファイルを全部閉じる.
inoremap qq <Esc><Cmd>qall<CR>
nnoremap qq <Cmd>qall<CR>
"=== visible tab,space,eol
set list
set listchars=tab:»-,trail:-,extends:»,precedes:«,nbsp:%,eol:↲
" NonText:eol, SpecialKey:tab,trail
highlight NonText ctermfg=DarkGreen guifg=DarkGreen
highlight SpecialKey ctermfg=DarkGreen guifg=DarkGreen
"=== OS dependant
if has("mac")
elseif has("win64")
command! Q call system('start https://qiita.com/hkuno/items/4557f3f8d6b27d2884f2')
elseif has("win32") " win32/win64
command! Q call system('start https://qiita.com/hkuno/items/4557f3f8d6b27d2884f2')
elseif has("win32unix") " msys/cygwin
command! Q call system('start https://qiita.com/hkuno/items/4557f3f8d6b27d2884f2')
elseif has("unix") " msys/WSL/Linux
command! Q call system('xdg-open https://qiita.com/hkuno/items/4557f3f8d6b27d2884f2')
endif
"=== local
if filereadable(expand($HOME.'/.vimrc_local'))
source $HOME/.vimrc_local
endif