-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.vimrc
More file actions
343 lines (278 loc) · 8.47 KB
/
Copy path.vimrc
File metadata and controls
343 lines (278 loc) · 8.47 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
if has('vim_starting')
set nocompatible
endif
filetype plugin on
" ============================================================================
" VARIABLES
"
" Bool
let s:true = 1
let s:false = 0
" Platform
let s:is_windows = has('win16') || has('win32') || has('win64')
let s:is_cygwin = has('win32unix')
let s:is_mac = !s:is_windows && !s:is_cygwin
\ && (has('mac') || has('macunix') || has('gui_macvim') ||
\ (!executable('xdg-open') && system('uname') =~? '^darwin'))
let s:is_linux = !s:is_mac && has('unix')
" Vimrc path
if s:is_windows
let $DOTVIM = expand('~/vimfiles')
let $VIMRC = expand('~/_vimrc')
let $GVIMRC = expand('~/_gvimrc')
else
let $DOTVIM = expand('~/.vim')
let $VIMRC = expand('~/.vimrc')
let $GVIMRC = expand('~/.gvimrc')
endif
" ============================================================================
" DEIN SETTINGS
"
" Directory settings
if s:is_mac
let s:cache_home = expand('~/.cache')
let s:dein_dir = s:cache_home . '/dein'
let s:dein_repo_dir = s:dein_dir . '/repos/github.com/Shougo/dein.vim'
elseif s:is_windows
let s:cache_home = expand('~\_cache')
let s:dein_dir = s:cache_home . '\dein'
let s:dein_repo_dir = s:dein_dir . '\repos\github.com\Shougo\dein.vim'
else
let s:cache_home = expand('~/.cache')
let s:dein_dir = s:cache_home . '/dein'
let s:dein_repo_dir = s:dein_dir . '/repos/github.com/Shougo/dein.vim'
endif
" TOML file path
if s:is_mac
let s:dein_toml = '~/.dein.toml'
elseif s:is_windows
let s:dein_toml = '~\_dein.toml'
else
let s:dein_toml = '~/.dein.toml'
endif
" Install dein
if &runtimepath !~# '/dein.vim'
if !isdirectory(s:dein_repo_dir)
execute '!git clone https://github.com/Shougo/dein.vim' s:dein_repo_dir
endif
if s:is_mac
execute 'set runtimepath^=' . fnamemodify(s:dein_repo_dir, ':p')
elseif s:is_windows
set runtimepath^=~\_cache\dein\repos\github.com\Shougo\dein.vim
"set runtimepath^=~\_cache\dein\repos\github.com\Shougo\dein.vim\
" ~this \ is NG
" if execute `fnamemodify(s:dein_repo_dir, ':p')` then,
" returned path is '~\_cache\dein\repos\github.com\Shougo\dein.vim\'
" ~
else
execute 'set runtimepath^=' . fnamemodify(s:dein_repo_dir, ':p')
endif
endif
" Load TOML
if dein#load_state(expand(s:dein_dir))
call dein#begin(s:dein_dir, [$MYVIMRC, s:dein_toml])
call dein#load_toml(s:dein_toml)
call dein#end()
call dein#save_state()
endif
" Install Plugins
if dein#check_install()
call dein#install()
endif
" ============================================================================
" GENERAL SETTINGS
"
set autoread
set backspace =indent,eol,start
set clipboard =unnamed,autoselect
set history =100
set tags =tags;
set viminfo ='1000,f1,:20,/10,%100
set iminsert =0
set imsearch =-1
set imdisable
set wildmode =longest:full,full
set nohidden
if has('mouse')
set mouse=a
endif
" Text, tab, indent (May be overriten by autocmd rules)
set expandtab
set foldmethod =indent
set foldlevel =9
set nowrap
set smarttab
set shiftwidth =2
set tabstop =4
set softtabstop=0
" Encoding
set encoding =utf-8
if s:is_mac
set fileencodings =utf-8,iso-2022-jp,euc-jp,cp932,sjis,utf16le
elseif s:is_windows
set fileencodings =iso-2022-jp,euc-jp,utf-8,cp932,sjis,utf16le
endif
"set fileencoding =utf-8
"set fileencodings =iso-2022-jp,euc-jp,utf-8,cp932,sjis,utf16le
"set fileencodings =iso-2022-jp,cp932,sjis,euc-jp,utf-16le,utf-8
"set bomb
"set binary
"set ttyfast
" Searching
set hls
set nohlsearch
set incsearch
set ignorecase
set smartcase
set magic
" Backup, Swap, Undo files
" Turn off all, since many files are in git
set nobackup
"set backupdir=~/tmp/vim_bkp
set noswapfile
"set directory=~/tmp/vim_swp
set noundofile
"set undodir=~/tmp/vim_undo
" Window
set splitbelow
set splitright
" QuickFix
" Auto open quickfix-window when grep
autocmd QuickFixCmdPost *grep* cwindow
" ============================================================================
" VISUAL SETTINGS
"
syntax on
set guicursor=a:blinkon0
set colorcolumn=0
set laststatus =2
set mousehide
set number
set ruler
set scrolloff =5
set showcmd
"set statusline =%<%f\ %m%r%h%w%{'['.(&fenc!=''?&fenc:&enc).']['.&ff.']'}%=%l/%L,%c%V%8P
set statusline=%<%f\ %h%m%r%=%{\"[\".(&fenc==\"\"?&enc:&fenc).((exists(\"+bomb\")\ &&\ &bomb)?\",BOM\":\"\").\"]\ \"}%k\ %-14.(%l,%c%V%)\ %P
set t_Co =256
set nolist
set nocursorline
hi clear CursorLine
if s:is_mac
set listchars=tab:»-,trail:-,extends:»,precedes:«,nbsp:%,eol:↲
end
" ============================================================================
" KEY MAPPING
"
let mapleader="\<Space>"
let maplocalleader=";"
nnoremap <space>, :e $MYVIMRC<cr>
" Edit
nnoremap <space>a ^
vnoremap <space>a ^
nnoremap <space>e $
vnoremap <space>e $
inoremap jj <ESC>
inoremap <ESC> <ESC>:set iminsert=0<cr>
" Window
nnoremap <space>w <c-w>
nnoremap <c-h> <c-w>h
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-l> <c-w>l
" Tab
nnoremap <space>tn :tabnew<cr>
" Netrw
nnoremap <space>E :Ex<cr>
nnoremap <space>he :Hex<cr>
nnoremap <space>ve :Vex<cr>
nnoremap <space>te :Tex<cr>
nnoremap <space>rex :Rex<cr>
" QuickFix
nnoremap <space>[ :cprevious<cr>zO
nnoremap <space>] :cnext<cr>zO
" File
nnoremap <space>cd :cd %:h<cr>
nnoremap <space>lcd :lcd %:h<cr>
" Search
nnoremap / :se hls<cr>/\v
nnoremap n nzz
nnoremap N Nzz
nnoremap * *zz
nnoremap # #zz
nnoremap g* g*zz
nnoremap g# g#zz
nnoremap <space>rep :%s///g<left><left>
nnoremap <space><esc> :<c-u>nohls<cr>
" Terminal
if has('nvim')
tnoremap <expr> <A-r> '<C-\><C-N>"'.nr2char(getchar()).'pi'
endif
" Snippet
inoremap :now <c-r>=strftime("%Y-%m-%d %H:%M:%S")<cr>
inoremap ;now <c-r>=strftime("%Y-%m-%d %H:%M:%S")<cr>
cnoremap :now <c-r>=strftime("%Y-%m-%d %H:%M:%S")<cr>
cnoremap ;now <c-r>=strftime("%Y-%m-%d %H:%M:%S")<cr>
inoremap :date <c-r>=strftime("%Y-%m-%d")<cr>
inoremap ;date <c-r>=strftime("%Y-%m-%d")<cr>
cnoremap :date <c-r>=strftime("%Y-%m-%d")<cr>
cnoremap ;date <c-r>=strftime("%Y-%m-%d")<cr>
inoremap :time <c-r>=strftime("%H:%M:%S")<cr>
inoremap ;time <c-r>=strftime("%H:%M:%S")<cr>
cnoremap :time <c-r>=strftime("%H:%M:%S")<cr>
cnoremap ;time <c-r>=strftime("%H:%M:%S")<cr>
" Ruby
nnoremap <space>rb :w<cr>:!ruby %<cr>
" Blog
inoremap :img ![img]()<esc>Pa=w740
"inoremap ;;img ![img]()<esc>P :s/=w\d\{1,4\}-h\d\{1,4\}-no/=w740/<cr>
nnoremap <space>bn :<c-u>tabnew<cr>:se ft=markdown<cr>:<c-u>cd ~/.ghq/github.com/yamagh/yamagh.github.io/_posts<cr>iblog
" Todo.txt
nnoremap <space>tt :e ~/Dropbox/todo/todo.txt<cr>
nnoremap <space>tf :e ~/Dropbox/todo/fun.todo.txt<cr>
" ============================================================================
" Functions
"
" ============================================================================
" QuickFix
"
set errorformat=%f\|%l\ col\ %c\|\ %m
" ============================================================================
" SetFileType
"
au BufNewFile,BufRead *.mdl,*.frm setf vb
" ============================================================================
" SETTINGS FOR Windows
"
if s:is_windows
set guifont=MS_Gothic:h9:cSHIFTJIS
set linespace=1
if has('kaoriya')
set ambiwidth=auto
source $VIM/plugins/kaoriya/encode_japan.vim
if !(has('win32') || has('mac')) && has('multi_lang')
if !exists('$LANG') || $LANG.'X' ==# 'X'
if !exists('$LC_CTYPE') || $LC_CTYPE.'X' ==# 'X'
language ctype ja_JP.eucJP
endif
if !exists('$LC_MESSAGES') || $LC_MESSAGES.'X' ==# 'X'
language messages ja_JP.eucJP
endif
endif
endif
endif
set guioptions-=T
" Menubar lang change to Japanese
if has('gui_running')
source $VIMRUNTIME/delmenu.vim
set langmenu=ja_jp.utf-8
source $VIMRUNTIME/menu.vim
endif
endif
" ============================================================================
" SETTINGS FOR Japanease
"
if has('multi_byte_ime') || has('xim')
highlight CursorIM guibg=Purple guifg=NONE
set iminsert=0 imsearch=0
endif
" vim:ft=vim ts=2: