-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathvimrc
More file actions
341 lines (285 loc) · 8.1 KB
/
vimrc
File metadata and controls
341 lines (285 loc) · 8.1 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
" ======================
" vim configuration file
" @author suzuken (https://github.com/suzuken)
"
" suzuken/dotfiles - GitHub
" https://github.com/suzuken/dotfiles
" ======================
" use https://github.com/junegunn/vim-plug
call plug#begin()
"Plugin Installing
Plug 'mattn/webapi-vim'
Plug 'vim-scripts/The-NERD-Commenter'
Plug 'mattn/gist-vim'
Plug 'mattn/emmet-vim'
Plug 'vim-scripts/Modeliner'
Plug 'tpope/vim-fugitive'
Plug 'thinca/vim-quickrun'
Plug 'vim-scripts/ShowMarks'
Plug 'mattn/benchvimrc-vim'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'mileszs/ack.vim'
Plug 'Shougo/vimproc.vim'
Plug 'mattn/ctrlp-ghq'
Plug 'majutsushi/tagbar'
Plug 'mattn/sonictemplate-vim'
Plug 'editorconfig/editorconfig-vim'
Plug 'justinmk/vim-dirvish'
Plug 'plasticboy/vim-markdown'
Plug 'uarun/vim-protobuf'
Plug 'tomtom/tlib_vim'
Plug 'MarcWeber/vim-addon-mw-utils'
Plug 'garbas/vim-snipmate'
let g:snipMate = { 'snippet_version' : 0 }
" Plugins for each languages
Plug 'puppetlabs/puppet-syntax-vim'
Plug 'wting/rust.vim', {'for': 'rust'}
Plug 'vim-ruby/vim-ruby', {'for': 'ruby'}
Plug 'fatih/vim-go', {'for': 'go'}
Plug 'hynek/vim-python-pep8-indent', {'for': 'python'}
Plug 'ekalinin/Dockerfile.vim'
call plug#end()
filetype plugin indent on
" =================
" showmarks_include
" =================
let g:showmarks_include="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
"==========================
"init
"==========================
set modelines=5
let mapleader = ","
set tabstop=4
set expandtab
set softtabstop=0
set shiftwidth=4
set smarttab
set number
set title
set scrolloff=5
set ambiwidth=double
set visualbell
set cmdheight=2
" highlight each language in markdown
" http://mattn.kaoriya.net/software/vim/20140523124903.htm
let g:markdown_fenced_languages = [
\ 'css',
\ 'go',
\ 'javascript',
\ 'js=javascript',
\ 'json=javascript',
\ 'ruby',
\ 'sass',
\ 'xml',
\ 'erlang',
\ 'sql',
\ 'perl',
\ 'php',
\]
"==========================
"Searching and Moving
"==========================
nnoremap / /\v
vnoremap / /\v
set ignorecase
set smartcase
set incsearch
set showmatch
set hlsearch
set wrapscan
" In visual mode, tab means insert <tab> into highlighted block.
vnoremap <Tab> >gv
vnoremap <S-Tab> <gv
" always escape / and ? in search character.
cnoremap <expr> /
\ getcmdtype() == '/' ? '\/' : '/'
cnoremap <expr> ?
\ getcmdtype() == '?' ? '\?' : '?'
"==========================
"Handling long lines
"==========================
set wrap
"==========================
"Key Bind
"==========================
" reload vimrc
" http://learnvimscriptthehardway.stevelosh.com/chapters/07.html
noremap <C-c><C-c> <C-c>
noremap <C-c><C-e>e :edit $MYVIMRC<CR>
noremap <C-c><C-e>s :source $MYVIMRC<CR>
" when move to search results, move to center.
noremap n nzz
noremap N Nzz
noremap * *zz
noremap # #zz
noremap g* g*zz
noremap g# g#zz
nnoremap ; :
"F2でpasteモードに。pasteするときにインデントを無効化。
" <F2> to paste mode.
set pastetoggle=<F2>
"splitの移動を簡単に。ctrl押しながらhjkl
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" <Enter> always means inserting line.
nnoremap <S-Enter> O<ESC>
nnoremap <Enter> o<ESC>
" Creating underline/overline headings for markup languages
" Inspired by http://sphinx.pocoo.org/rest.html#sections
nnoremap <leader>1 yyPVr=jyypVr=
nnoremap <leader>2 yyPVr*jyypVr*
nnoremap <leader>3 yyPVr-jyypVr-
nnoremap <leader>4 yypVr=
nnoremap <leader>5 yypVr-
nnoremap <leader>6 yypVr^
nnoremap <leader>7 yypVr"
"==========================
"language
"==========================
set encoding=utf-8
source $HOME/.vim/encode.vim
set fileformats=unix,dos,mac
"==========================
"clipboard
"==========================
set clipboard+=autoselect
"==========================
"special Key
"==========================
set list
set listchars=tab:>-,trail:-,extends:<,precedes:<
highlight specialKey ctermfg=darkgray
"==========================
"Input
"==========================
set backspace=indent,eol,start
set formatoptions+=mM
set autoindent
set smartindent
"==========================
"Command
"==========================
set wildmenu
set wildmode=full:list
"==========================
"Programming
"==========================
set foldmethod=syntax
set grepprg=internal "内蔵grep
"==========================
"Backup
"==========================
set autowrite
set hidden
set backup
set backupdir=$HOME/.vimback
set directory=$HOME/.vimtmp
set history=10000
set updatetime=500
"==========================
"Status Line
"==========================
set showcmd "ステータスラインにコマンドを表示
set laststatus=2 "ステータスラインを常に表示
"==========================
"Window
"==========================
set splitright "Window Split時に新Windowを右に表示
set splitbelow "Window Split時に新windowを下に表示
"==========================
"File Type
"==========================
syntax on "シンタックスハイライト
if has('autocmd')
autocmd BufNewFile * silent! 0r $HOME/.vim/templates/%:e.tpl
autocmd FileType python setl autoindent
autocmd FileType python setl smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
autocmd FileType python setl tabstop=4 expandtab shiftwidth=4 softtabstop=4
autocmd FileType html :compiler tidy
autocmd FileType html :setlocal makeprg=tidy\ -raw\ -quiet\ -errors\ --gnu-emacs\ yes\ \"%\"
autocmd FileType html setl tabstop=2 expandtab shiftwidth=2 softtabstop=2
autocmd BufNewFile,BufRead *.q set filetype=sql
autocmd BufNewFile,BufRead *.twig set filetype=html
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
endif
"==========================
"help
"==========================
set helplang=en
augroup my_dirvish_events
au!
au User DirvishEnter let b:dirvish.showhidden = 1
augroup END
let g:dirvish_relative_paths = 1
"==========================
"NERDcommenter.vim
"==========================
let g:NERDSpaceDelims = 1
let g:NERDShutUp = 1
" =====================================================
"" ctags
" =====================================================
set tags=tags
" =====================================================
"" sonictemplate
" =====================================================
let g:sonictemplate_vim_template_dir = [
\ '$HOME/.vim/templates',
\]
" =====================================================
"" tagbar
" =====================================================
noremap <leader>t :<c-u>TagbarToggle<cr>
" =====================================================
"" ack.vim
" =====================================================
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
" =====================================================
"" ctrlp.vim
" =====================================================
let g:ctrlp_regexp = 0
let g:ctrlp_extensions = ['tag', 'buffertag', 'dir', 'mixed', 'bookmarkdir']
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]\.(git|hg|svn)$',
\ 'file': '\v\.(exe|so|dll|class)$',
\ 'link': 'SOME_BAD_SYMBOLIC_LINKS',
\ }
" ctrlp-ghq
" https://github.com/mattn/ctrlp-ghq
noremap <leader>g :<c-u>CtrlPGhq<cr>
" quickrun
let g:quickrun_config = {}
nnoremap <Leader>r :QuickRun<CR>
" jad
" installation required http://varaneckas.com/jad/
augr class
au!
au bufreadpost,filereadpost *.class %!jad -noctor -ff -i -p %
au bufreadpost,filereadpost *.class set readonly
au bufreadpost,filereadpost *.class set ft=java
au bufreadpost,filereadpost *.class normal gg=G
au bufreadpost,filereadpost *.class set nomodified
augr END
"----------------------------------------------------
"" host specific
"----------------------------------------------------
if filereadable(expand("~/.vimrc.local"))
source ~/.vimrc.local
endif
function! HandleURI()
let s:uri = matchstr(getline("."), '[a-z]*:\/\/[^>,;:]*')
echo s:uri
if s:uri != ""
exec "!open \"" . s:uri . "\""
else
echo "No URI found in line."
endif
endfunction
map <Leader>w :call HandleURI()<CR>
" http://stackoverflow.com/questions/916875/yank-file-name-path-of-current-buffer-in-vim
" set full path of current buffer to unamed register
nmap cp :let @" = expand("%")