-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
381 lines (289 loc) · 8.96 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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
""""""""""""""""""""""""""""""""""""""""""""""""""
" General
""""""""""""""""""""""""""""""""""""""""""""""""""
" Get out of vi's compatible mode
set nocompatible
" How many lines of history
set history=500
" Set to auto read when a file is changed from the outside
"set autoread
" Set map leader
let mapleader = ","
let g:mapleader = ","
" Fast saving
nmap <LEADER>w :w<CR>
" Fast reloading of the .vimrc
map <LEADER>s :source ~/.vimrc<CR>
" Fast editing of .vimrc
map <LEADER>e :e! ~/.vimrc<CR>
" When .vimrc is edited, reload it
autocmd! bufwritepost vimrc source ~/.vimrc
" Show commands as they are typed
set showcmd
""""""""""""""""""""""""""""""""""""""""""""""""""
" Encoding
""""""""""""""""""""""""""""""""""""""""""""""""""
" Use UTF-8
set encoding=utf-8
" Save file as UTF-8
set fileencoding=utf-8
" List of charsets to recognize
set fileencodings=utf-8,big5,euc-jp,gbk,euc-kr,utf-bom,iso8859-1
" Terminal encoding
set termencoding=utf-8
" Treat ambiguous characters as full width
set ambiwidth=double
""""""""""""""""""""""""""""""""""""""""""""""""""
" Colours and Fonts
""""""""""""""""""""""""""""""""""""""""""""""""""
set t_Co=256
" Enable syntax highlighting
syntax enable
" Set colour scheme
colorscheme molokai
" Highlight current line in insert mode
function! s:EnterInsert()
set cursorline
endfunction
function! s:LeaveInsert()
set nocursorline
endfunction
autocmd InsertLeave * call s:LeaveInsert()
autocmd InsertEnter * call s:EnterInsert()
" Set cursorline
"hi cursorline cterm=none ctermbg=darkgrey
" Omni menu colors
"hi Pmenu ctermbg=darkgrey
"hi PmenuSel ctermbg=darkblue
" Pattern matching
"hi MatchParen ctermbg=11
""""""""""""""""""""""""""""""""""""""""""""""""""
" File formats
""""""""""""""""""""""""""""""""""""""""""""""""""
" Favourite file formats
set ffs=unix,dos
nmap <LEADER>fd :se ff=dos<CR>
nmap <LEADER>fu :se ff=unix<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""
" Filetypes
""""""""""""""""""""""""""""""""""""""""""""""""""
" Enable filetype plugin
filetype plugin on
filetype indent on
autocmd! BufRead,BufNewFile *.conf set filetype=config
" Vala
autocmd BufRead *.vala,*.vapi set efm=%f:%l.%c-%[%^:]%#:\ %t%[%^:]%#:\ %m
au BufRead,BufNewFile *.vala,*.vapi setfiletype vala
" Python
autocmd FileType python setlocal foldmethod=indent smartindent shiftwidth=4 ts=4 et cinwords=if,elif,else,for,while,try,except,finally,def,class
autocmd FileType vue setlocal foldmethod=indent smartindent shiftwidth=2 ts=4 et
""""""""""""""""""""""""""""""""""""""""""""""""""
" Interface
""""""""""""""""""""""""""""""""""""""""""""""""""
" Turn on wild menu
set wildmenu
" Show current position
set ruler
" Show line number
set number
" Don't redraw while running macros (faster)
"set lz
" Change buffer without saving
set hid
" Set backspace
set backspace=start,indent,eol
" Which keys to wrap
set whichwrap+=<,>,h,l
" Default value
set magic
" No sound for errors
set noerrorbells
" Show matching brackets
set showmatch
" Status line
set laststatus=2
"set statusline=%<%f%<%{FileTime()}%<%h%m%r%=%-20.(line=%03l,col=%02c%V,totlin=%L%)\%h%m%r%=%-30(,BfNm=%n%Y%)\%P\*%=%{CurTime()}
set rulerformat=%15(%c%V\ %p%%%)
"set cmdheight=2
" The following command scrolls the text so that (when possible) there are
" always at least five lines visible above the cursor, and five lines visible
" below the cursor:
set scrolloff=5
" change the terminal's title
set title
""""""""""""""""""""""""""""""""""""""""""""""""""
" Search
""""""""""""""""""""""""""""""""""""""""""""""""""
" Ignore case
set ignorecase
" Show first match
set incsearch
" Highlight search results
set hls
" Default value
set wrapscan
""""""""""""""""""""""""""""""""""""""""""""""""""
" Tabs
""""""""""""""""""""""""""""""""""""""""""""""""""
"nmap cr= $F=a<SPACE><ESC>lcf;
"nmap cl= $F=hc^
" Hot keys
nmap <C-T>c :tabnew<CR>
nmap <C-T>k :tabclose<CR>
nmap <C-H> :tabprev<CR>
" Alt+left arrow inside tmux
nmap [1;3D :tabprev<CR>
imap [1;3D <C-O>:tabprev<CR>
" Alt+left arrow outside tmux
nmap [1;9D :tabprev<CR>
imap [1;9D <C-O>:tabprev<CR>
nmap <C-L> :tabnext<CR>
" Alt+right arrow inside tmux
nmap [1;3C :tabnext<CR>
imap [1;3C <C-O>:tabnext<CR>
" Alt+right arrow outside tmux
nmap [1;9C :tabnext<CR>
imap [1;9C <C-O>:tabnext<CR>
set switchbuf=usetab
" Always show tab line
set stal=2
""""""""""""""""""""""""""""""""""""""""""""""""""
" Misc
""""""""""""""""""""""""""""""""""""""""""""""""""
autocmd BufNewFile,BufRead *.js,*.htc,*.c,*.tmpl,*.css inoremap $c /**<CR> **/<ESC>O
" Remove indenting on empty lines
noremap <F2> :%s/\s*$//g<CR>:noh<CR>''
" Big5
noremap <LEADER>b :e ++enc=big5<CR>:set tenc=big5<CR>
" UTF-8
noremap <LEADER>u :e ++enc=utf-8<CR>:set tenc=utf-8<CR>
map <Shift-CR> O<Esc>
map <CR> o<Esc>
" Set : and ; same as :
nnoremap ; :
nnoremap : :
""""""""""""""""""""""""""""""""""""""""""""""""""
" Temp and Backups
""""""""""""""""""""""""""""""""""""""""""""""""""
set backup
set backupdir=~/.vim/backup
set directory=~/.vim/tmp
set nowb
set noswapfile
set noar
""""""""""""""""""""""""""""""""""""""""""""""""""
" Folding
""""""""""""""""""""""""""""""""""""""""""""""""""
" Default values
set foldenable
set fdl=0
"nnoremap <SPACE> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""
" Text
""""""""""""""""""""""""""""""""""""""""""""""""""
set noexpandtab
set lbr
set wrap
set autoindent
set showmode
set tabstop=4
set shiftwidth=4
" Then, when in insert mode, ready to paste, if you press <F2>, Vim will
" switch to paste mode, disabling all kinds of smartness and just pasting a
" whole buffer of text. Then, you can disable paste mode again with another
" press of <F2>.
set pastetoggle=<F2>
""""""""""""""""""""""""""""""""""""""""""""""""""
" Spell check
""""""""""""""""""""""""""""""""""""""""""""""""""
set nospell
set spelllang=en
hi clear SpellBad
"map <LEADER>sn ]s
"map <LEADER>sp [s
"map <LEADER>sa zg
"map <LEADER>s? z=
map <F5> :set spell!<CR><BAR>:echo "Spell check: " . strpart("OffOn", 3 * &spell, 3)<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""
" Quickfix
""""""""""""""""""""""""""""""""""""""""""""""""""
" command -bang -nargs=? QFix call QFixToggle(<bang>0)
" function! QFixToggle(forced)
" if exists("g:qfix_win") && a:forced == 0
" cclose
" unlet g:qfix_win
" else
" copen 10
" let g:qfix_win = bufnr("$")
" endif
" endfunction
" nnoremap <leader>q :QFix<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""
" Plugins
""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""
" Taglist
""""""""""""""""""""""""""""""""""""""""
"let Tlist_Ctags_Cmd = '/usr/local/bin/exctags'
let Tlist_Auto_Update = 1
let Tlist_Sort_Type = "name"
let Tlist_WinWidth = 30
let Tlist_Show_One_File = 0
let Tlist_Exit_OnlyWindow = 1
let Tlist_Use_SingleClick = 1
let Tlist_File_Fold_Auto_Close = 1
let Tlist_Process_File_Always = 1
let Tlist_Enable_Fold_Column = 0
let Tlist_Use_Right_Window = 1
nnoremap <F3> :TlistToggle<CR>
""""""""""""""""""""""""""""""""""""""""
" Cscope
""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""
" Slippery Snippet
""""""""""""""""""""""""""""""""""""""""
let g:snip_start_tag = "«"
let g:snip_end_tag = "»"
let g:snippetsEmu_key = "<C-B>"
""""""""""""""""""""""""""""""""""""""""
" Nerd Tree
""""""""""""""""""""""""""""""""""""""""
" How to use?
"
" o Open selected file, or expand selected dir
" go Open selected file, but leave cursor in the NERDTree
" t Open selected node in a new tab
" T Same as 't' but keep the focus on the current tab
" <tab> Open selected file in a split window
" g<tab> Same as <tab>, but leave the cursor on the NERDTree
" ! Execute the current file
" O Recursively open the selected directory
" x Close the current nodes parent
" X Recursively close all children of the current node
" e Open a netrw for the current dir
nnoremap <F4> :NERDTreeToggle<CR>
""""""""""""""""""""""""""""""""""""""""
" Nerd Commenter
""""""""""""""""""""""""""""""""""""""""
let g:NERDMapleader = ";c"
""""""""""""""""""""""""""""""""""""""""
" SuperTab
""""""""""""""""""""""""""""""""""""""""
let g:SuperTabDefaultCompletionType = "<C-N>"
""""""""""""""""""""""""""""""""""""""""
" OmniCppComplete
""""""""""""""""""""""""""""""""""""""""
map <F6> :!exctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
set listchars=tab:>-,trail:-,eol:$,nbsp:%,extends:>,precedes:<
" PHP
let php_sql_query=1
let php_htmlInStrings=1
let php_folding=1
let php_noShortTags=1
set nomodeline
xmap <Leader>s <Plug>Vsurround
""""""""""""""""""""""""""""""""""""""""""""""""""
" Pathogen.vim
" http://vimcasts.org/episodes/synchronizing-plugins-with-git-submodules-and-pathogen/
""""""""""""""""""""""""""""""""""""""""""""""""""
execute pathogen#infect()