-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvimrc
More file actions
290 lines (218 loc) · 6.67 KB
/
vimrc
File metadata and controls
290 lines (218 loc) · 6.67 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
" Plugins
" =======
call plug#begin()
" Editor
" ------
Plug 'w0rp/ale'
Plug 'jiangmiao/auto-pairs'
Plug 'gregsexton/MatchTag'
Plug 'scrooloose/nerdcommenter'
Plug 'ervandew/supertab'
Plug 'alvan/vim-closetag'
Plug 'terryma/vim-multiple-cursors'
Plug 'garbas/vim-snipmate'
Plug 'tomtom/tlib_vim'
Plug 'MarcWeber/vim-addon-mw-utils'
Plug 'honza/vim-snippets'
Plug 'bronson/vim-trailing-whitespace'
" Movement
" --------
Plug 'ctrlpvim/ctrlp.vim'
Plug 'scrooloose/nerdtree'
Plug 'mhinz/vim-grepper'
Plug 'ludovicchabant/vim-gutentags'
Plug 'airblade/vim-rooter'
" Language Support
" ----------------
Plug 'jamessan/vim-gnupg'
Plug 'kamailio/vim-kamailio-syntax'
Plug 'sheerun/vim-polyglot'
" Git
" ---
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'tpope/vim-fugitive'
Plug 'airblade/vim-gitgutter'
call plug#end()
" Plugin configuration
" ====================
" ALE
" ---
let g:ale_fixers = { 'javascript': ['eslint', 'prettier'] }
" Closetag
" --------
let g:closetag_filenames = "*.html,*.xhtml,*.phtml,*.jsx,*.js,*.tt,*.ejs"
" CtrlP
" -----
let g:ctrlp_match_window = 'top,max:20,order:ttb'
let g:ctrlp_show_hidden = 1
let g:ctrlp_working_path_mode = 'ra'
" Multiple cursors
" ----------------
let g:multi_cursor_exit_from_visual_mode = 0
let g:multi_cursor_exit_from_insert_mode = 0
" NerdCommenter
" -------------
let NERDSpaceDelims = 1
" NerdTree
" --------
let g:NERDTreeDirArrows = 1
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" SuperTab
" --------
let g:SuperTabDefaultCompletionType = '<c-n>'
" Vim config
" ==========
set nocompatible
syntax on
set background=dark
set autowrite
set history=500
set ignorecase
set incsearch
set ruler
set scrolloff=3
set showcmd
set showmatch
set tabpagemax=100
set wildmenu
set clipboard=
" Jump to the last position when reopening a file
" -----------------------------------------------
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal g'\"" | endif
" Highlight tabs
" --------------
set list
set listchars=tab:»·
set listchars+=trail:·
set listchars+=extends:>
set listchars+=precedes:<
" Enable spell checking
" ---------------------
set spell
highlight clear SpellBad
highlight SpellBad term=underline cterm=underline
highlight clear SpellCap
highlight SpellCap term=underline cterm=underline
highlight clear SpellRare
highlight SpellRare term=underline cterm=underline
highlight clear SpellLocal
highlight SpellLocal term=underline cterm=underline
" Syntax highlighting for unknown file types
" ------------------------------------------
autocmd BufNewFile,BufRead *.tt setf html
autocmd BufNewFile,BufRead *.phtml setf html
autocmd BufNewFile,BufRead *.ejs setf html
" Shortcuts
" =========
" Switch to next/previous buffer with <Alt-right/left>
" ----------------------------------------------------
map <a-right> :bn<cr>
imap <a-right> :bn<cr>
vmap <a-right> :bn<cr>
map <a-left> :bp<cr>
imap <a-left> :bp<cr>
vmap <a-left> :bp<cr>
" Step through the program with <Ctrl-j/k/l>
" ------------------------------------------
map <c-j> zz
map <c-k> :tnext<cr>
map <c-l> <C-T>
" Search with :grep or <Ctrl-f>
" -----------------------------
cabbrev grep <c-r>=(getcmdtype()==':' && getcmdpos()==1 ? 'Grepper -query' : 'grep')<CR>
map <c-f> :Grepper -cword -noprompt<cr>
" Open fuzzy finder with <Ctrl-o>
" -------------------------------
let g:ctrlp_map = '<c-o>'
let g:ctrlp_cmd = 'CtrlP .'
if executable('ag')
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
let g:ctrlp_use_caching = 0
endif
" Open directory view with <Ctrl-p>
" ---------------------------------
map <c-p> :NERDTreeToggle<cr>
imap <c-p> <esc>:NERDTreeToggle<cr>
" Jump to next/previous function with <Ctrl-up/down>
" --------------------------------------------------
autocmd FileType perl map <c-up> ?^sub <cr>zz
autocmd FileType perl imap <c-up> <esc>?^sub <cr>zz
autocmd FileType perl map <c-down> /^sub <cr>zz
autocmd FileType perl imap <c-down> <esc>/^sub <cr>zz
autocmd FileType php,javascript map <c-up> ?function <cr>zz
autocmd FileType php,javascript imap <c-up> <esc>?function <cr>zz
autocmd FileType php,javascript map <c-down> /function <cr>zz
autocmd FileType php,javascript imap <c-down> <esc>/function <cr>zz
autocmd FileType python map <c-up> ?^def <cr>zz
autocmd FileType python imap <c-up> <esc>?^def <cr>zz
autocmd FileType python map <c-down> /^def <cr>zz
autocmd FileType python imap <c-down> <esc>/^def <cr>zz
" Move lines up/down with <Alt-up/down>
" -------------------------------------
nnoremap <a-up> :m .-2<CR>==
nnoremap <a-down> :m .+1<CR>==
inoremap <a-up> <Esc>:m .-2<CR>==gi
inoremap <a-down> <Esc>:m .+1<CR>==gi
vnoremap <a-up> :m '<-2<CR>gv=gv
vnoremap <a-down> :m '>+1<CR>gv=gv
" Re factor with <R/L/K>
" ----------------------
let g:multi_cursor_next_key = 'R'
let g:multi_cursor_prev_key = 'L'
let g:multi_cursor_skip_key = 'K'
" Start multiple cursors with <Ctrl-m>
" ------------------------------------
vmap <c-m> R
" Insert debug code with <Ctrl-d>
" -------------------------------
autocmd FileType c imap <c-d> printf("%s\n", );<left><left>
autocmd FileType java imap <c-d> System.out.println();<left><left>
autocmd FileType javascript imap <c-d> console.log();<left><left>
autocmd FileType perl imap <c-d> print Dumper $;<left>
autocmd FileType php imap <c-d> var_dump($);<left><left>
autocmd FileType python imap <c-d> import sys; print >> sys.stderr,<space>
" Toggle git blame view with <Ctrl-b>
" -----------------------------------
map <c-b> :Gblame<cr>
imap <c-b> <esc>:Gblame<cr>
" Toggle git status view with <Ctrl-g>
" ------------------------------------
map <c-g> :Gstatus<cr>
imap <c-g> <esc>:Gstatus<cr>
" Fix spelling with <Ctrl-s>
" --------------------------
map <c-s> z=
imap <c-s> <esc>z=
" Write a file using sudo with :w!!
" ---------------------------------
cmap w!! w !sudo tee % >/dev/null
" Toggle paste mode with <F5>
" ---------------------------
set pastetoggle=<F5>
" Toggle comment with <F8>
" ------------------------
map <F8> <leader>c<space>
vmap <F8> <leader>c<space>
imap <F8> <esc><leader>c<space>
" Toggle indentation with <F11>
" -----------------------------
function TabToggle()
if &expandtab
set shiftwidth=8
set softtabstop=0
set noexpandtab
else
set shiftwidth=2
set softtabstop=2
set expandtab
endif
endfunction
map <F11> mz:execute TabToggle()<CR>'z
vmap <F11> mz:execute TabToggle()<CR>'z
imap <F11> <esc>mz:execute TabToggle()<CR>'zi
" Reformat file with <F12>
" ------------------------
map <F12> :ALEFix<cr>
vmap <F12> :ALEFix<cr>
imap <F12> <esc>:ALEFix<cr>i