-
Notifications
You must be signed in to change notification settings - Fork 4
/
vimrc
291 lines (239 loc) · 6.22 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
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Bundle Sources
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
so ~/.vim/bundles.vim
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" General Settings
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set encoding detection
set fileencodings=utf-8,gb2312,gb18030,gbk,ucs-bom,cp936,latin1
" Enable file type detection
filetype plugin on
filetype indent on
" Enable syntax highlight and completion
syntax enable
syntax on
" Set default color scheme
if has("gui_running")
set gfn=WenQuanYi\ Micro\ Hei\ Mono\ 10
color monokai
else
color desert
endif
" Enable omni completion.
au FileType css setlocal omnifunc=csscomplete#CompleteCSS
au FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
au FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
au FileType python setlocal omnifunc=pythoncomplete#Complete
au FileType c setlocal omnifunc=ccomplete#Complete
" Set Omni menu colors
hi Pmenu guibg=#333333
hi PmenuSel guibg=#555555 guifg=#ffffff
" Set configurations
set nocompatible
set autoread
set wildmenu
set ruler
set nu
set lz
set hid
set ignorecase
set smartcase
set incsearch
set magic
set noerrorbells
set novisualbell
set showmatch
set showcmd
set title
set hlsearch
set nobackup
set nowb
set noswapfile
set fen
set expandtab
set smarttab
set lbr
set ai
set smartindent
set cindent
set wrap
set timeout
"set cursorline
"set cursorcolumn
"set confirm
set timeoutlen=500
set matchtime=2
set matchpairs+=<:>
set report=0
set shiftwidth=4
set tabstop=4
set fmr={,}
set fdm=marker
set fdl=10
set mouse=a
set history=300
set t_Co=256
set background=dark
set ffs=unix,dos,mac
set so=7
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
set laststatus=2
set completeopt=menu
set pastetoggle=<F3>
" Highlight current line
"au WinLeave * set nocursorline nocursorcolumn
"au WinEnter * set cursorline cursorcolumn
" Set leader
let mapleader = ","
let g:mapleader = ","
" Fast Save
nmap <leader>w :w!<cr>
imap <leader>w <esc>:w!<cr>
" Fast reload vimrc
map <leader>s :source ~/.vimrc<cr>
" Fast format file
nmap <leader>fd :se ff=dos<cr>
nmap <leader>fu :se ff=unix<cr>
" Fast switch tab
map <leader>to :tabnew
map <leader>tw :tabnew %<cr>
map <leader>tc :tabclose<cr>
map <leader>tn :tabnext<cr>
map <leader>tp :tabprevious<cr>
map <leader>te :tabedit
map <leader>tm :tabmove
" Fast adjust shift width
map <leader>s2 :set shiftwidth=2<cr>
map <leader>s4 :set shiftwidth=4<cr>
" Fast switch syntax
map <leader>1 :set syntax=cheetah<cr>
map <leader>2 :set syntax=html<cr>
map <leader>3 :set syntax=python<cr>
map <leader>4 :set syntax=javascript<cr>
map <leader>5 :set syntax=c<cr>
map <leader>6 :set syntax=java<cr>
map <leader>7 :set syntax=nginx<cr>
map <leader>8 :set syntax=perl<cr>
map <leader>9 :set syntax=vb<cr>
map <leader>$ :syntax sync fromstart<cr>
" Fast format indent of the whole file
map <leader>g gg=G
" Fast spell checking
map <leader>sn ]s
map <leader>sp [s
map <leader>sa zg
map <leader>sd zw
map <leader>s? z=
" Fast remove highlight
map <silent> <leader><cr> :noh<cr>
" Fast remove windows ^M
noremap <leader>m mmHmt:%s/<c-v><cr>//ge<cr>'tzt'm
" Fast select content from current line to bottom
nnoremap <leader>v V`]
" Fast move line up and down, like sublime text
imap <c-up> <esc>ddkPi
imap <c-down> <esc>ddpi
imap <leader>b0 <esc>v0di
imap <leader>b$ <esc>v$di
imap <leader>b <esc>xi
" Fast trigger plug-in
nnoremap <leader>t :TagbarToggle<cr>
nnoremap <leader>e :NERDTreeToggle<cr>
nnoremap <leader>a :Ack
nnoremap <c-u> :GundoToggle<cr>
nnoremap <c-p> :CtrlP<cr>
" Fash run shell
map <leader><space> :!
" Fast search
"map <space> /
"map <c-space> ?
" Fast switch window
map <c-j> <c-w>j
map <c-k> <c-w>k
map <c-h> <c-w>h
map <c-l> <c-w>l
" Fast to close window
"map <c-q> <c-w>q
" Fast switch buffers
map <c-up> :BufExplorer<CR>
map <c-left> :bp<cr>
map <c-right> :bn<cr>
map <c-down> :bd<cr>
" Fast copy&paste with clipboard
vmap <c-F7> "+y<cr>
nmap <c-F8> 0i<F3><c-r>+<esc><F3>
" Fast remove indenting on empty lines
map <F2> :%s/\s*$//g<cr>:noh<cr>''
" FIXME work around the conflicts under tmux
map <F5> :BufExplorer<CR>
"map << :bp<cr>
"map >> :bn<cr>
vmap <F7> "+y<cr>
nmap <F8> 0i<F3><c-r>+<esc><F3>
" Fast input
iab _date <c-r>=strftime("%d/%m/%y")
iab _time <c-r>=strftime("%H:%M:%S")
iab _now <c-r>=strftime("%H:%M:%S %d/%m/%y")
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Special Settings for different file type
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Python
au FileType python let python_highlight_all = 1
au FileType python let python_highlight_builtins = 1
au FileType python let python_highlight_exceptions = 1
au FileType python let python_highlight_string_formatting = 1
au FileType python let python_highlight_string_format = 1
au FileType python let python_highlight_string_templates = 1
au FileType python let python_highlight_indent_errors = 1
au FileType python let python_highlight_space_errors = 1
au FileType python let python_highlight_doctests = 1
au FileType python so ~/.vim/syntax/python.vim
au FileType python so ~/.vim/plugin/python_fold.vim
au FileType python so ~/.vim/plugin/python_fn.vim
" Javascript & JQuery
au FileType javascript set shiftwidth=2
au Syntax javascript set syntax=jquery
" Configuration File
" au! BufRead,BufNewFile *.conf setfiletype cfg
" Go
" C/C++
"
" Java
"
" PHP
"
" HTML & XML
au FileType html set ft=htmldjango
au FileType html,xml set shiftwidth=2
" Perl
"
" Ruby
"
" Shell
"
" JSON
"
"
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Personal Settings
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Fast input
so ~/.vim/plugin/myfastinput.vim
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Loading configurations for bundle plugins
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
so ~/.vim/config.vim
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" TODO
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Fast go to front and back
"imap <m-$> <esc>$a
"imap <m-0> <esc>0i
"cno $h e ~/
"cno $d e ~/Desktop
"cno $c e ~/Code
"cno $t e /tmp
"cno <c-a> <home>
"cno <c-e> <end>