/
.vimrc
218 lines (163 loc) · 4.37 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
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
" Editor-Settings{{{
" Encoding{{{
" Use utf-8 to overall encoding.
set encoding=utf-8
scriptencoding utf-8
" Use utf-8 when file write.
set fileencoding=utf-8
" Use file encodings when loaded.
set fileencodings=utf-8,sjis,iso-2022-jp,euc-jp
" }}}
" Automatic line feed code recognition.
set fileformats=unix,dos
let s:cache_dir = expand('~/.cache/vim')
" make backup file.
let s:backupdir = s:cache_dir . '/backup'
if !isdirectory(s:backupdir)
call mkdir(s:backupdir, 'p')
endif
execute 'set backupdir=' . s:backupdir
set backup
" make swap file.
let s:swapdir = s:cache_dir . '/swap'
if !isdirectory(s:swapdir)
call mkdir(s:swapdir, 'p')
endif
execute 'set directory=' . s:swapdir
set swapfile
" make undo file.
let s:undodir = s:cache_dir . '/undo'
if isdirectory(s:undodir)
call mkdir(s:undodir, 'p')
endif
execute 'set undodir=' . s:undodir
set undofile
" East asia ambigunous charactor width problem.
set ambiwidth=single
" Automatically load the file being edited
set autoread
" Move the cursor one character ahead of the end of the line
set virtualedit=block
" Use the clipboard on linux systems.
set clipboard+=unnamedplus
" diff vertical view
set diffopt+=vertical,algorithm:histogram,indent-heuristic
" no beep
set belloff=all
" }}}
" Display{{{
" Display rows number.
set number
" Display relative rows number.
set relativenumber
" Display current row cursorline.
set cursorline
" }}}
" Folding{{{
set foldmethod=marker
set foldlevel=0
set foldcolumn=3
" }}}
" Search{{{
" Highlight search results
set hlsearch
" Incremental search.
" Search starts when you enter the first character of the search word.
set incsearch
" Search is not case sensitive
set ignorecase
" Searching in lowercase ignores uppercase and lowercase
set smartcase
" When the search progresses to the end of the file, search again from the beginning of the file.
set wrapscan
" }}}
" Indent{{{
" Smart indent.
set smartindent
" Insert tab with half-width space.
set expandtab
" The amount of blank space to insert with each command or smart indent.
set shiftwidth=2
" Tab width with 2 spaces.
set tabstop=2
" Insert a tab with 2 minutes of half-width space.
set softtabstop=2
augroup filetypeIndent
autocmd!
autocmd FileType html setlocal tabstop=2 softtabstop=2 shiftwidth=2
autocmd FileType css setlocal tabstop=2 softtabstop=2 shiftwidth=2
autocmd FileType python setlocal tabstop=4 softtabstop=4 shiftwidth=4
autocmd FileType php setlocal tabstop=4 softtabstop=4 shiftwidth=4
augroup END
" }}}
" Statusline{{{
" Display statusline.
set laststatus=2
" Command line completion.
set wildmenu
" Command history.
set history=5000
" }}}
" Invisible characters{{{
" Invisible characters
set list
"Tab/End line Space/End line/No brake space.
set listchars=tab:»-,space:・,trail:・,nbsp:%,eol:↲,extends:»,precedes:«
" }}}
" Keybind settings.
" Window control keybind {{{
" overwrites window command of 'CTRL-W'.
" Use prefix <Plug>(window).
nmap <Space>w <Plug>(window)
" Commands of move between window.
nnoremap <Plug>(window)h <C-W>h
nnoremap <Plug>(window)j <C-W>j
nnoremap <Plug>(window)k <C-W>k
nnoremap <Plug>(window)l <C-W>l
" Commands of move window.
nnoremap <Plug>(window)H <C-W>H
nnoremap <Plug>(window)J <C-W>J
nnoremap <Plug>(window)K <C-W>K
nnoremap <Plug>(window)L <C-W>L
" Tab page controls.
nnoremap [t gT
nnoremap ]t gt
nnoremap [T <Cmd>tabfirst<CR>
nnoremap ]T <Cmd>tablast<CR>
nnoremap <Plug>(window)tn <Cmd>tabnew<CR>
nnoremap <Plug>(window)tT <C-W>T
" Commands of close window.
nnoremap <Plug>(window)q <C-W>q
nnoremap <Plug>(window)Q <Cmd>quit!<CR>
" easy save. save file only when changed.
nnoremap <Plug>(window)w <Cmd>update<CR>
" Commands of window split.
nnoremap <Plug>(window)s <C-W>s
nnoremap <Plug>(window)v <C-W>v
nnoremap <Plug>(window)n <C-W>n
" Window size controls.
nnoremap <Plug>(window)<Bar> <C-W><Bar>
nnoremap <Plug>(window)_ <C-W>_
nnoremap <Plug>(window)= <C-W>=
" }}}
" Normal Mode:{{{
" Do not save the things erased by x and c in the register.
nnoremap x "_x
nnoremap c "_c
" Opens the file name under the cursor.
nnoremap gf gF
" Disable highlights from search results.
nnoremap <C-l> <Cmd>nohlsearch<Bar>diffupdate<CR><C-l>
" }}}
" Insert Mode:{{{
" Exit insert mode.
inoremap jj <ESC>
inoremap <C-l> <Del>
" }}}
" Visual Mode:{{{
" Do not save the things erased by x and c in the register.
xnoremap x "_x
xnoremap c "_c
" }}}
filetype plugin indent on
syntax on