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
|
" NOTE: This .vimrc is minimal and not well-maintained because I have migrated
" from Vim to Neovim.
set encoding=utf-8
scriptencoding utf-8
if empty($XDG_DATA_HOME)
let s:data_home = $HOME . '/.local/share'
else
let s:data_home = $XDG_DATA_HOME
endif
let s:my_env = {
\ 'backup_dir': s:data_home . '/vim/backup',
\ 'swap_dir': s:data_home . '/vim/swap',
\ 'undo_dir': s:data_home . '/vim/undo',
\ 'viminfo': s:data_home . '/vim/viminfo',
\ }
for [s:k, s:v] in items(s:my_env)
if s:k =~# '_dir$' && !isdirectory(s:v)
call mkdir(s:v, 'p')
endif
endfor
unlet s:k s:v s:data_home
language messages C
language time C
syntax on
filetype plugin indent on
set nowrapscan
set incsearch
set ignorecase
set smartcase
set scrolloff=7
set wrap
set linebreak
set breakindent
set breakindentopt+=sbr
let &showbreak = '> '
set sidescrolloff=20
set display=lastline
let &fillchars = 'vert: ,fold: ,diff: '
set list
let &listchars = "eol: ,tab:> ,trail:^,extends:>,precedes:<"
set concealcursor=cnv
set synmaxcol=500
set hlsearch
set t_Co=256
set colorcolumn=+1
set laststatus=2
set winminheight=0
set hidden
set switchbuf=usetab
set showtabline=1
set notitle
set mouse=
set shortmess+=a
set shortmess+=s
set shortmess+=I
set shortmess+=c
set showcmd
set noshowmode
set report=999
set confirm
set belloff=all
set clipboard=unnamed
set undofile
let &undodir = s:my_env.undo_dir
set textwidth=0
set backspace=indent,eol,start
set completeopt-=preview
set pumheight=10
set noshowmatch
set matchpairs+=<:>
set nojoinspaces
set nrformats-=octal
if has('patch-8.2.0860')
set nrformats+=unsigned
endif
set tabstop=4
set shiftwidth=4
set smarttab
set softtabstop=4
set expandtab
set autoindent
set smartindent
set copyindent
set preserveindent
set foldlevelstart=0
set foldopen+=insert
set foldmethod=marker
set diffopt+=vertical
set diffopt+=foldcolumn:3
set maxmapdepth=10
set notimeout
set ttimeout
set ttimeoutlen=100
set nofixendofline
set fileformats=unix,dos
set backup
let &backupdir = s:my_env.backup_dir
set autowrite
set autoread
let &directory = s:my_env.swap_dir . '//'
set history=2000
set wildignore+=*.o,*.obj,*.lib
set wildignorecase
set wildmenu
set shell=zsh
set keywordprg=
set fileencodings=utf-8,cp932,euc-jp
set sessionoptions+=localoptions
set sessionoptions+=resize
set sessionoptions+=winpos
let &viminfofile = s:my_env.viminfo
augroup Vimrc
autocmd!
augroup END
autocmd Vimrc VimResized * wincmd =
autocmd Vimrc BufRead *
\ if 0 < line("'\"") && line("'\"") <= line('$') &&
\ &filetype !~# 'commit' && &filetype !~# 'rebase' |
\ execute "normal g`\"" |
\ endif
if has('patch-9.0.1799')
packadd editorconfig
function! SetIsEditorConfigApplied(config)
let b:__editorconfig__ = {}
if has_key(a:config, 'indent_style')
let b:__editorconfig__.expandtab = 1
endif
if has_key(a:config, 'tab_width')
let b:__editorconfig__.tabstop = 1
endif
if has_key(a:config, 'indent_size')
let b:__editorconfig__.shiftwidth = 1
let b:__editorconfig__.softtabstop = 1
endif
return 0
endfunction
call editorconfig#AddNewHook(function('SetIsEditorConfigApplied'))
endif
function! SetIndentStyle(prefer_spaces, indent_size)
let editorconfig = get(b:, '__editorconfig__', {})
if !has_key(editorconfig, 'expandtab')
let &expandtab = a:prefer_spaces
endif
if !has_key(editorconfig, 'tabstop')
let &tabstop = a:indent_size
endif
if !has_key(editorconfig, 'shiftwidth')
let &shiftwidth = a:indent_size
endif
if !has_key(editorconfig, 'softtabstop')
let &softtabstop = a:indent_size
endif
endfunction
autocmd Vimrc FileType c call SetIndentStyle(1, 4)
autocmd Vimrc FileType cmake call SetIndentStyle(1, 2)
autocmd Vimrc FileType cpp call SetIndentStyle(1, 4)
autocmd Vimrc FileType css call SetIndentStyle(1, 2)
autocmd Vimrc FileType docbk call SetIndentStyle(1, 2)
autocmd Vimrc FileType go call SetIndentStyle(1, 4)
autocmd Vimrc FileType haskell call SetIndentStyle(1, 4)
autocmd Vimrc FileType html call SetIndentStyle(1, 2)
autocmd Vimrc FileType javascript call SetIndentStyle(1, 2)
autocmd Vimrc FileType javascriptreact call SetIndentStyle(1, 2)
autocmd Vimrc FileType json call SetIndentStyle(1, 2)
autocmd Vimrc FileType leaf call SetIndentStyle(1, 4)
autocmd Vimrc FileType lisp call SetIndentStyle(1, 2)
autocmd Vimrc FileType lua call SetIndentStyle(1, 3)
autocmd Vimrc FileType markdown call SetIndentStyle(1, 4)
autocmd Vimrc FileType nix call SetIndentStyle(1, 2)
autocmd Vimrc FileType php call SetIndentStyle(1, 2)
autocmd Vimrc FileType python call SetIndentStyle(1, 4)
autocmd Vimrc FileType ruby call SetIndentStyle(1, 2)
autocmd Vimrc FileType satysfi call SetIndentStyle(1, 2)
autocmd Vimrc FileType sbt call SetIndentStyle(1, 2)
autocmd Vimrc FileType scala call SetIndentStyle(1, 2)
autocmd Vimrc FileType toml call SetIndentStyle(1, 2)
autocmd Vimrc FileType typescript call SetIndentStyle(1, 2)
autocmd Vimrc FileType typescriptreact call SetIndentStyle(1, 2)
autocmd Vimrc FileType vim call SetIndentStyle(1, 4)
autocmd Vimrc FileType xml call SetIndentStyle(1, 2)
autocmd Vimrc FileType yaml call SetIndentStyle(1, 2)
noremap <expr> gn v:searchforward ? 'gn' : 'gN'
noremap <expr> gN v:searchforward ? 'gN' : 'gn'
noremap <expr> n v:searchforward ? 'n' : 'N'
noremap <expr> N v:searchforward ? 'N' : 'n'
nnoremap <silent> & :%&&<CR>
xnoremap <silent> & :%&&<CR>
nnoremap <C-r> "
xnoremap <C-r> "
let @j = 'j.'
let @k = 'k.'
let @n = 'n.'
let @m = 'N.'
nnoremap @N @m
nnoremap @a 9999@@
nnoremap ` @@
inoremap <C-d> <Del>
inoremap <C-b> <C-g>U<Left>
inoremap <C-f> <C-g>U<Right>
inoremap <C-u> <C-g>u<C-u>
inoremap <C-w> <C-g>u<C-w>
cnoremap <C-a> <Home>
cnoremap <C-e> <End>
cnoremap <C-f> <Right>
cnoremap <C-b> <Left>
cnoremap <C-n> <Down>
cnoremap <C-p> <Up>
cnoremap <C-d> <Del>
cnoremap <Left> <Nop>
inoremap <Left> <Nop>
cnoremap <Right> <Nop>
inoremap <Right> <Nop>
nnoremap c "_c
xnoremap c "_c
nnoremap C "_C
xnoremap C "_C
noremap g= =
noremap ml gu
noremap mu gU
noremap gu <Nop>
noremap gU <Nop>
xnoremap u <Nop>
xnoremap U <Nop>
xnoremap x "_x
nnoremap Y y$
xnoremap <expr> Y mode() ==# 'V' ? 'y' : 'Vy'
nnoremap R gR
nnoremap gR R
nnoremap r gr
nnoremap gr r
nnoremap U <C-r>
noremap H ^
noremap L $
noremap M %
noremap gw b
noremap gW B
noremap k gk
noremap j gj
noremap gk k
noremap gj j
nnoremap gff gF
nnoremap <silent> tt :<C-u>tabnew<CR>
nnoremap <silent> tn :<C-u><C-r>=(tabpagenr() + v:count1 - 1) % tabpagenr('$') + 1<CR>tabnext<CR>
nnoremap <silent> tp :<C-u><C-r>=(tabpagenr('$') * 10 + tabpagenr() - v:count1 - 1) % tabpagenr('$') + 1<CR>tabnext<CR>
nnoremap <silent> tN :<C-u>tabmove +<CR>
nnoremap <silent> tP :<C-u>tabmove -<CR>
nnoremap <silent> tsh :<C-u>leftabove vsplit<CR>
nnoremap <silent> tsj :<C-u>rightbelow split<CR>
nnoremap <silent> tsk :<C-u>leftabove split<CR>
nnoremap <silent> tsl :<C-u>rightbelow vsplit<CR>
nnoremap <silent> tsH :<C-u>topleft vsplit<CR>
nnoremap <silent> tsJ :<C-u>botright split<CR>
nnoremap <silent> tsK :<C-u>topleft split<CR>
nnoremap <silent> tsL :<C-u>botright vsplit<CR>
nnoremap <silent> twh :<C-u>leftabove vnew<CR>
nnoremap <silent> twj :<C-u>rightbelow new<CR>
nnoremap <silent> twk :<C-u>leftabove new<CR>
nnoremap <silent> twl :<C-u>rightbelow vnew<CR>
nnoremap <silent> twH :<C-u>topleft vnew<CR>
nnoremap <silent> twJ :<C-u>botright new<CR>
nnoremap <silent> twK :<C-u>topleft new<CR>
nnoremap <silent> twL :<C-u>botright vnew<CR>
nnoremap th <C-w>h
nnoremap tj <C-w>j
nnoremap tk <C-w>k
nnoremap tl <C-w>l
nnoremap tH <C-w>H
nnoremap tJ <C-w>J
nnoremap tK <C-w>K
nnoremap tL <C-w>L
nnoremap tx <C-w>x
nnoremap tRH <C-w>_
nnoremap tRW <C-w><Bar>
nnoremap tRR <C-w>_<C-w><Bar>
nnoremap t= <C-w>=
nnoremap <silent> tq :<C-u>bdelete<CR>
nnoremap tc <C-w>c
nnoremap to <C-w>o
nnoremap <silent> tO :<C-u>tabonly<CR>
nnoremap T <Nop>
nnoremap <silent> Tb :<C-u>if &background == 'dark' <Bar>set background=light <Bar>else <Bar>set background=dark <Bar>endif<CR>
nnoremap <silent> Tc :<C-u>set cursorcolumn! <Bar>set cursorline!<CR>
nnoremap <silent> Td :<C-u>if &diff <Bar>diffoff <Bar>else <Bar>diffthis <Bar>endif<CR>
nnoremap <silent> Te :<C-u>set expandtab!<CR>
nnoremap <silent> Th :<C-u>set hlsearch!<CR>
nnoremap <silent> Tn :<C-u>set number!<CR>
nnoremap <silent> Ts :<C-u>set spell!<CR>
nnoremap <silent> T8 :<C-u>if &textwidth ==# 80 <Bar>set textwidth=0 <Bar>else <Bar>set textwidth=80 <Bar>endif<CR>
nnoremap <silent> T0 :<C-u>if &textwidth ==# 100 <Bar>set textwidth=0 <Bar>else <Bar>set textwidth=100 <Bar>endif<CR>
nnoremap <silent> T2 :<C-u>if &textwidth ==# 120 <Bar>set textwidth=0 <Bar>else <Bar>set textwidth=120 <Bar>endif<CR>
nnoremap <silent> Tw :<C-u>set wrap!<CR>
nmap TB Tb
nmap TC Tc
nmap TD Td
nmap TE Te
nmap TH Th
nmap TN Tn
nmap TS Ts
nmap TW Tw
nnoremap gh <Nop>
nnoremap gH <Nop>
nnoremap g<C-h> <Nop>
nnoremap Q <Nop>
nnoremap gQ <Nop>
nnoremap ZZ <Nop>
nnoremap ZQ <Nop>
nnoremap <C-h> :<C-u>help<Space>
onoremap <silent> gv :<C-u>normal! gv<CR>
nnoremap ; :
nnoremap : ;
xnoremap ; :
xnoremap : ;
nnoremap @; @:
xnoremap @; @:
cnoremap <C-r>; <C-r>:
inoremap <C-r>; <C-r>:
imap jk <ESC>
cmap jk <ESC>
nnoremap <silent> <C-c> :<C-u>nohlsearch<CR>
nnoremap <silent> <Space>w :<C-u>update<CR>
nnoremap <silent> <nowait> Z :<C-u>wqall<CR>
inoreabbrev TOOD TODO
inoreabbrev retrun return
inoreabbrev reutrn return
inoreabbrev tihs this
cnoreabbrev S %s
set background=dark
colorscheme desert
let &statusline = ' %f %r %m %= %l/%L %{&fileencoding} %{&fileformat} %y '
|