aboutsummaryrefslogtreecommitdiffhomepage
path: root/.vimrc
blob: a2c62ea48cf69812d0fb632c4ff4e4e92c09e0c8 (plain)
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
" 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
set nrformats+=unsigned

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


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.'
nnoremap   @N  N.
nnoremap  @a  9999@@
nnoremap  `  @@

inoremap  <C-d>  <Del>

inoremap <expr>  <C-a>  repeat("\<C-g>U\<Left>", col('.') - 1)
inoremap <expr>  <C-e>  repeat("\<C-g>U\<Right>", col('$') - col('.'))
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  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>write<CR>


inoreabbrev  retrun  return
inoreabbrev  reutrn  return
inoreabbrev  tihs  this


set background=dark
colorscheme desert


let &statusline = ' %f %r %m %= %l/%L %{&fileencoding} %{&fileformat} %y '