-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
339 lines (275 loc) · 8.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
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
set nocompatible
set enc=utf-8
set fencs=utf-8
set ambiwidth=double
set ignorecase
set smartcase
set wrapscan
set incsearch
set hlsearch
set autoindent
set smartindent
set cindent
set tabstop=2
set shiftwidth=2
set expandtab
set number
set noruler
set nolist
set showmatch
set wrap
set title
set showcmd
set cmdheight=2
set laststatus=2
set statusline=%F%m%r%h%w\ [%{&ff}][%{&fenc!=''?&fenc:&enc}][%Y][pos:%04l,%04v][%p%%][rows:%L]
set wildmenu
set nocursorline
set backspace=2
set scrolloff=5
set formatoptions+=mM
set nobackup
set history=1000
set mouse=a
" set autochdir
set restorescreen
set hidden
set browsedir=current
set nohlsearch
set nowrapscan
" set tags=~/dev/study/_vim/.tags
set imdisable
set iminsert=1
set imsearch=1
syntax on
" ====================================================
" vundle settings
"
" To install vundle
" mkdir .vim/bundle
" cd .vim/bundle
" git clone http://github.com/gmarik/vundle.git
" ====================================================
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle
" required!
Bundle 'gmarik/vundle'
" My Bundles here:
"
" original repos on github
Bundle 'tpope/vim-fugitive'
Bundle 'Lokaltog/vim-easymotion'
"Bundle 'rstacruz/sparkup', {'rtp': 'vim/'}
" vim-scripts repos
Bundle 'L9'
Bundle 'FuzzyFinder'
Bundle 'vcscommand.vim'
Bundle 'octave.vim'
Bundle 'QuickBuf'
Bundle 'scratch'
Bundle 'skk.vim-B'
Bundle 'sudo.vim'
Bundle 'The-NERD-tree'
Bundle 'neocomplcache'
Bundle 'Syntastic'
Bundle 'vim-coffee-script'
" non github repos
Bundle 'git://git.wincent.com/command-t.git'
" Brief help
" :BundleList - list configured bundles
" :BundleInstall(!) - install(update) bundles
" :BundleSearch(!) foo - search(or refresh cache first) for foo
" :BundleClean(!) - confirm(or auto-approve) removal of unused bundles
"
" see :h vundle for more details or wiki for FAQ
" NOTE: comments after Bundle command are not allowed..
" ====================================================
" SKK
let skk_jisyo = "/Users/t-nishibayashi/Library/Application Support/AquaSKK/skk-jisyo.utf8"
let skk_large_jisyo = "/Users/t-nishibayashi/Library/Application Support/AquaSKK/SKK-JISYO.L"
let skk_egg_like_newline = 1
let skk_kutouten_jp = ".,"
filetype indent on
filetype plugin indent on
filetype plugin on
autocmd FileType ruby set tabstop=2 tw=0 sw=2 expandtab
autocmd FileType eruby set tabstop=2 tw=0 sw=2 expandtab
autocmd FileType html set tabstop=2
autocmd FileType javascript set tabstop=2 tw=0 sw=2 fenc=utf-8 expandtab
autocmd FileType python set tabstop=4 tw=0 sw=4 fenc=utf-8 expandtab fileencoding=utf-8
autocmd FileType c hi Comment ctermfg=darkcyan
autocmd FileType cpp hi Comment ctermfg=darkcyan
autocmd FileType cpp set tabstop=4 tw=0 sw=4 fenc=utf-8 expandtab
autocmd FileType coffee set tabstop=2 tw=2
autocmd FileType rst set fenc=utf-8
autocmd BufRead /tmp/crontab.* :set nobackup nowritebackup
autocmd BufNewFile,BufRead app/*/*.rhtml set ft=mason fenc=utf-8
autocmd BufNewFile,BufRead app/**/*.rb set ft=ruby fenc=utf-8
autocmd BufNewFile,BufRead app/**/*.yml set ft=ruby fenc=utf-8
autocmd BufNewFile *.php 0r $HOME/.vim/template/php.txt
autocmd FileType GITCOMMIT set fenc=utf-8
autocmd FileType VCSCOMMIT set fenc=utf-8
autocmd FileType php set tabstop=4 tw=0 sw=4 fenc=utf-8 expandtab
autocmd BufRead,BufNewFile *.twig set syntax=htmldjango
"autocmd BufWrite *.* :call didSaveFile()
"function! didSaveFile()
"
"endfunction
" =========================================
" Plugin settings
" =========================================
let format_join_spaces = 4
let format_allow_over_tw = 1
" rails.vim
let g:rails_level=4
let g:rails_default_file="app/controllers/application.rb"
let g:rails_default_database="sqlite3"
" rubycomplete.vim
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1
autocmd FileType ruby,eruby let g:rubycomplete_rails = 1
autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1
" neocomplecache
let g:neocomplcache_enable_at_startup = 1
let g:neocomplcache_auto_completion_start_length = 4
let g:neocomplcache_manual_completion_start_length = 4
let g:neocomplcache_enable_ignore_case = 1
let g:neocomplcache_enable_smart_case = 1
" path
let &path="~/dev/workspace,~"
let main_syntax="html"
"======================= Key Mappings ======================
let mapleader = ','
nnoremap <Space>w :<C-u>update<CR>
nnoremap <Space>. :<C-u>edit $MYVIMRC<Enter>
nnoremap <Space>s. :<C-u>source $MYVIMRC<Enter>
" help
nnoremap <expr> <Space>h ':<C-u>help ' . expand('<cword>') . '<CR>'
" line feed
noremap j gj
noremap k gk
noremap gj j
noremap gk k
" scratch.vim
nnoremap <leader>so :<C-u>ScratchOpen<CR>
nnoremap <leader>sc :<C-u>ScratchClose<CR>
" Use ClipBoard
vmap <silent> sy :!pbcopy; pbpaste<CR>
map <silent> sp v:!pbpaste<CR>
" javascript
" autocmd FileType javascript nnoremap ,jsl :!gjslint --custom_jsdoc_tags 'xtype,event,singleton' %<CR>
autocmd FileType javascript nnoremap ,jsl :!SyntasticCheck<CR>
autocmd FileType javascript nnoremap ,jsf :!fixjsstyle --custom_jsdoc_tags 'xtype,event,singleton' %<CR>
autocmd FileType javascript inoremap <buffer> fff function(
autocmd FileType javascript inoremap <buffer> eee assert.equal(
autocmd FileType javascript inoremap <buffer> iie console.error();<LEFT><LEFT>
autocmd FileType javascript inoremap <buffer> iii console.log();<LEFT><LEFT>
autocmd FileType javascript inoremap <buffer> iid console.dir();<LEFT><LEFT>
" python
autocmd FileType python nnoremap <leader>py :<C-u>!python %<Enter>
" insert date
inoremap <expr> ,df strftime('%Y-%m-%dT%H:%M:%S')
inoremap <expr> ,dd strftime('%Y-%m-%d')
inoremap <expr> ,dt strftime('%H:%M:%S')
" select last changed text
nnoremap gc `[v`]
vnoremap gc :<C-u>normal gc<Enter>
onoremap gc :<C-u>normal gc<Enter>
" search
nmap n nzz
nmap N Nzz
nmap * *zz
nmap # #zz
nmap g* g*zz
nmap g# g#zz
" Auto complete
vnoremap { "zdi{<C-R>z}<ESC>
vnoremap [ "zdi[<C-R>z]<ESC>
vnoremap ( "zdi(<C-R>z)<ESC>
vnoremap " "zdi"<C-R>z"<ESC>
vnoremap ' "zdi'<C-R>z'<ESC>
" buffer control
nnoremap <C-N> :bn<CR>
nnoremap <C-P> :bp<CR>
nnoremap <F3> :bd<CR>
" window
nnoremap <C-J> <C-W>j
nnoremap <C-K> <C-W>k
nnoremap <C-L> <C-W>l
nnoremap <C-H> <C-W>h
" tab
nnoremap <Space>n :<C-u>tabn<CR>
nnoremap <Space>p :<C-u>tabp<CR>
" filefinder
nnoremap <leader>fr :<C-u>FufBuffer<CR>
nnoremap <leader>fe :<C-u>FufFile<CR>
nnoremap <leader>ff :<C-u>FufCoverageFile<CR>
" hg
nnoremap <leader>hd :<C-u>HgDiff<CR>
" VCS
nnoremap <leader>cd :<C-u>VCSDiff<CR>
nnoremap <leader>cc :<C-u>VCSCommit<CR>
" NERD_tree
map <leader>d :execute 'NERDTreeToggle ' . getcwd()<CR>
" makefile
nnoremap <leader>mc :<C-u>!make concat<CR>
nnoremap <leader>mt :<C-u>!make test<CR>
" rakefile
nnoremap <leader>rc :<C-u>!rake concat<CR>
nnoremap <leader>rd :<C-u>!rake debug<CR>
nnoremap <leader>rt :<C-u>!rake test<CR>
if has('multi_byte_ime') || has('xim')
" 日本語入力ON時のカーソルの色を設定
highlight CursorIM guibg=Purple guifg=NONE
endif
hi Search term=reverse ctermbg=Darkcyan ctermfg=NONE
colorscheme ron
" edit binary file
"augroup BinaryXXD
" autocmd!
" autocmd BufReadPre *.bin let &binary =1
" autocmd BufReadPost * if &binary | silent %!xxd -g 1
" autocmd BufReadPost * set ft=xxd | endif
" autocmd BufWritePre * if &binary | %!xxd -r | endif
" autocmd BufWritePost * if &binary | silent %!xxd -g 1
" autocmd BufWritePost * set nomod | endif
"augroup END
"
"
autocmd BufRead svn* call TemplateSVN()
function! TemplateSVN()
set fileencoding=utf-8
endfunction
augroup vimrc-auto-cursorline
autocmd!
autocmd CursorMoved,CursorMovedI * call s:auto_cursorline('CursorMoved')
autocmd CursorHold,CursorHoldI * call s:auto_cursorline('CursorHold')
autocmd WinEnter * call s:auto_cursorline('WinEnter')
autocmd WinLeave * call s:auto_cursorline('WinLeave')
let s:cursorline_lock = 0
function! s:auto_cursorline(event)
if a:event ==# 'WinEnter'
setlocal cursorline
let s:cursorline_lock = 2
elseif a:event ==# 'WinLeave'
setlocal nocursorline
elseif a:event ==# 'CursorMoved'
if s:cursorline_lock
if 1 < s:cursorline_lock
let s:cursorline_lock = 1
else
setlocal nocursorline
let s:cursorline_lock = 0
endif
endif
elseif a:event ==# 'CursorHold'
setlocal cursorline
let s:cursorline_lock = 1
endif
endfunction
augroup END
" memo
" show messages
" :messages