forked from qiao/vimfiles
-
Notifications
You must be signed in to change notification settings - Fork 3
/
vimrc
227 lines (179 loc) · 5.83 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
" Don't be compatible with vi
set nocompatible
filetype off
" Use Vundle to manage plugins
set rtp+=~/.vim/bundle/vundle
call vundle#begin()
source ~/.vim/vimrc.bundles
call vundle#end()
filetype plugin indent on
" More powerful backspacing
set backspace=indent,eol,start
" Larger history storage
set history=1000
" Enalbe syntax highlighting
syntax on
" Set column limit for syntax highlighting
" to prevent longs lines slowing down the world
set synmaxcol=128
" Optimize scrolling
set ttyfast
set ttyscroll=3
set lazyredraw
" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
set background=dark
" Color settings
set t_Co=256
color tir_black
set cursorline
" JQuery syntax support
autocmd Syntax javascript set syntax=jquery
" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif
" Matching
set showmatch " Show matching brackets.
set smartcase " Do smart case matching
set incsearch " Incremental search
set ignorecase " Do case insensitive matching
" Status
set showcmd " Show (partial) command in status line.
set laststatus=2 " Always show status bar
set ruler " Show cursor position
set number " Show line number
" Indentation
set expandtab
set tabstop=2
set shiftwidth=2
set softtabstop=2
set linespace=2
set autoindent
autocmd Syntax python,html,css,ruby,javascript,coffee set tabstop=4 shiftwidth=4 linespace=4
" File Types
autocmd BufRead,BufNewFile *.g set syntax=antlr3
" Indent guides (default toggle key is <leader>ig)
let g:indent_guides_auto_colors=0
let g:indent_guides_start_level=2
let g:indent_guides_guide_size=1
autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd ctermbg=239
autocmd VimEnter,Colorscheme * :hi IndentGuidesEven ctermbg=242
" NeoComplCache
let g:neocomplcache_force_overwrite_completefunc = 1
let g:neocomplcache_enable_at_startup=1
let g:neocomplcache_enable_smart_case=1
let g:neocomplcache_min_syntax_length = 3
let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*'
let g:neosnippet#disable_runtime_snippets = { "_": 1, }
autocmd Syntax html let g:neocomplcache_disable_auto_complete=1
set completeopt-=preview
" Snippet
" Enable snipMate compatibility feature.
let g:neosnippet#enable_snipmate_compatibility = 1
" Tell Neosnippet about the other snippets
let g:neosnippet#snippets_directory='~/.vim/bundle/vim-snippets/snippets'
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
imap <expr><TAB> neosnippet#expandable_or_jumpable() ? "\<Plug>(neosnippet_expand_or_jump)" : pumvisible() ? "\<C-n>" : "\<TAB>"
smap <expr><TAB> neosnippet#expandable_or_jumpable() ? "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" For snippet_complete marker.
if has('conceal')
set conceallevel=2 concealcursor=i
endif
" SuperTab
let g:SuperTabDefaultCompletionType="<c-n>"
" Zen-coding
let g:user_emmet_expandabbr_key='<c-j>'
let g:user_emmet_settings={
\ 'indentation': ' ',
\}
" Nerd Tree
let NERDChristmasTree=1
let NERDTreeWinSize=25
" set filter
let NERDTreeIgnore=['\.mat$', '.*\.mex.*', 'tags', '.*\.jpg$', '.*\.png$', '.*\.jpeg$', '.*\.bmp$',
\ '\.o$', '.*\~', '.*\.swp$', '\.DS_Store$', '.*\.class$', '\.pyc$',
\ '\.pdf$', '\.svn$',
\ '\.dsp$', '\.dsw$', '\.ncb$', '\.opt$', '\.sln$', '\.suo$', '\.vcxproj$', '\.plg$' , '\.sdf$']
let NERDTreeShowHidden=1
let NERDTreeAutoCenter=1
" Tab Bar
let g:Tb_MaxSize = 2
let g:Tb_TabWrap = 1
" Tagbar
let g:tagbar_left=0
let g:tagbar_width=30
" Rainbow parentheses for Lisp and variants
let g:rbpt_colorpairs = [
\ [172, 172],
\ [167, 167],
\ [141, 141],
\ [39, 39],
\ [49, 49],
\ [82, 82],
\ [11, 11],
\ [172, 172],
\ [167, 167],
\ [141, 141],
\ [39, 39],
\ [49, 49],
\ [82, 82],
\ [11, 11],
\ [172, 172],
\ [167, 167],
\ ]
let g:rbpt_max = 32
autocmd Syntax lisp,scheme,clojure RainbowParenthesesToggle
" Key mappings
"nmap <F2> :set hlsearch! hlsearch?<CR>
nmap <F3> :set paste! paste?<CR>
nmap <F4> :IndentGuidesToggle<CR>
nmap <F5> :NERDTreeToggle<CR>
nmap <F6> :TagbarToggle<CR>
nmap <F7> :Autoformat<CR><CR>
" the following three commands need gvim
" sudo apt-get install vim-gnome
" copy content of current file to system clipboard
nmap <C-c> ggVG"+y''
" copy the selected content to system clipboard
vmap <C-c> "+y
" paste content of system clipboard
nmap <C-p> "+p
" delete current tab, remove it from tagbar
nmap <C-x> :Tbbd<CR>
" For local replace
nnoremap gr gd[{V%:s/<C-R>///gc<left><left><left>
" For global replace
nnoremap gR gD:%s/<C-R>///gc<left><left><left>
" w!! to sudo & wirte a file
cmap w!! w !sudo tee > /dev/null %
" Extra commands
command W w
command WQ wq
command Wq wq
command Q q
command Qa qa
command QA qa
" disable auto comment
"set paste
" set highlight search
set hlsearch
" set EasyMotion_leader_key
let g:EasyMotion_leader_key = '<Leader>'
" alias unnamed register to the + register, which is the X Window clipboard
"set clipboard=unnamedplus
" set fileencodings to avoid messy code
" set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
set fileencodings=utf-8,gb2312,gb18030,gbk,ucs-bom,cp936,latin1
set enc=utf8
set fencs=utf8,gbk,gb2312,gb18030
" set the cursor as the last viewing line of the file
" If this doesn't work, a common problem is not having ownership of your
" ~/.viminfo file. If this is the case, then run:
" sudo chown user:group ~/.viminfo
au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif
" ignore whitespace
"set diffopt+=iwhite
" force wrap line in vimdiff
autocmd FilterWritePre * if &diff | setlocal wrap< | endif