-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
323 lines (245 loc) · 9.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
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
" ~/.vimrc
"""""""""""""""""""""""""""""""""" Vundle """"""""""""""""""""""""""""""""""
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
""""""""""" auto-pairs
Plugin 'jiangmiao/auto-pairs'
let g:AutoPairsFlyMode = 0
let g:AutoPairsShortcutBackInsert = '<M-b>'
""""""""""" ctrlp.vim
Plugin 'kien/ctrlp.vim'
set wildignore+=*/tmp/*,*.a,*.la,*.so,*.so.*,*.swp,*.zip,*.tar.gz,.git,.svn,*.deb,*.rpm
""""""""""" minibufexpl.vim
Plugin 'fholgado/minibufexpl.vim'
"let g:miniBufExplModSelTarget = 1
"let g:miniBufExplorerMoreThanOne = 0
"let g:miniBufExplUseSingleClick = 1
"let g:miniBufExplMapWindowNavVim = 1
"let g:miniBufExplVSplit = 30
"let g:miniBufExplSplitBelow= 1
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplModSelTarget = 1
map <Leader>e :MBEOpen<cr>
map <Leader>c :MBEClose<cr>
map <Leader>t :MBEToggle<cr>
nnoremap <F12> :MBEToggle<CR>
" MiniBufExpl Colors
hi MBENormal guifg=#808080 guibg=fg
hi MBEChanged guifg=#CD5907 guibg=fg
hi MBEVisibleNormal guifg=#5DC2D6 guibg=fg
hi MBEVisibleChanged guifg=#F1266F guibg=fg
hi MBEVisibleActiveNormal guifg=#A6DB29 guibg=fg
hi MBEVisibleActiveChanged guifg=#F1266F guibg=fg
""""""""""" nerdcommenter
Plugin 'scrooloose/nerdcommenter'
" Add spaces after comment delimiters by default
let g:NERDSpaceDelims = 1
" Use compact syntax for prettified multi-line comments
let g:NERDCompactSexyComs = 1
" Align line-wise comment delimiters flush left instead of following code indentation
let g:NERDDefaultAlign = 'left'
" Set a language to use its alternate delimiters by default
let g:NERDAltDelims_java = 1
" Add your own custom formats or override the defaults
let g:NERDCustomDelimiters = { 'c': { 'left': '/**','right': '*/' } }
" Allow commenting and inverting empty lines (useful when commenting a region)
let g:NERDCommentEmptyLines = 1
" Enable trimming of trailing whitespace when uncommenting
let g:NERDTrimTrailingWhitespace = 1
"使用语法高亮定义代码折叠
set foldmethod=syntax
"打开文件是默认不折叠代码
set foldlevelstart=99"
""""""""""" nerdtree
Plugin 'scrooloose/nerdtree'
"autocmd vimenter * NERDTree
map <C-n> :NERDTreeToggle<CR>
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
""""""""""" numbers.vim
Plugin 'myusuf3/numbers.vim'
let g:numbers_exclude = ['tagbar', 'gundo', 'minibufexpl', 'nerdtree']
nnoremap <F3> :NumbersToggle<CR>
nnoremap <F4> :NumbersOnOff<CR>
""""""""""" rainbow
Plugin 'luochen1990/rainbow'
let g:rainbow_active = 1
let g:rainbow_conf = {
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick'],
\ 'ctermfgs': ['lightblue', 'lightyellow', 'lightcyan', 'lightmagenta'],
\ 'operators': '_,_',
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'],
\ 'separately': {
\ '*': {},
\ 'tex': {
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/'],
\ },
\ 'lisp': {
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick', 'darkorchid3'],
\ },
\ 'vim': {
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/', 'start=/{/ end=/}/ fold', 'start=/(/ end=/)/ containedin=vimFuncBody', 'start=/\[/ end=/\]/ containedin=vimFuncBody', 'start=/{/ end=/}/ fold containedin=vimFuncBody'],
\ },
\ 'html': {
\ 'parentheses': ['start=/\v\<((area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)[ >])@!\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'|[^ '."'".'"><=`]*))?)*\>/ end=#</\z1># fold'],
\ },
\ 'css': 0,
\ }
\}
""""""""""" SQLComplete.vim
Plugin 'vim-scripts/SQLComplete.vim'
""""""""""" syntastic
Plugin 'scrooloose/syntastic'
""""""""""" tagbar
Plugin 'majutsushi/tagbar'
nmap <F8> :TagbarToggle<CR>
""""""""""" vim-airline
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
set t_Co=256
set laststatus=2
let g:airline_theme = "tomorrow"
"let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#buffer_nr_show = 1
function! AccentDemo()
let keys = ['l','u','o','x','u','3','4','@']
for k in keys
call airline#parts#define_text(k, k)
endfor
call airline#parts#define_accent('l', 'red')
call airline#parts#define_accent('u', 'green')
call airline#parts#define_accent('o', 'blue')
call airline#parts#define_accent('x', 'yellow')
call airline#parts#define_accent('u', 'orange')
call airline#parts#define_accent('3', 'purple')
call airline#parts#define_accent('4', 'bold')
call airline#parts#define_accent('@', 'italic')
let g:airline_section_a = airline#section#create(keys)
endfunction
autocmd VimEnter * call AccentDemo()
""""""""""" vim-colors-solarized
Plugin 'altercation/vim-colors-solarized'
""""""""""" vim-fugitive
Plugin 'tpope/vim-fugitive'
""""""""""" vim-indent-guides
Plugin 'nathanaelkane/vim-indent-guides'
let g:indent_guides_enable_on_vim_startup = 0
let g:indent_guides_guide_size = 1
let g:indent_guides_auto_colors = 0
autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd guibg=#262626 ctermbg=235 "238
autocmd VimEnter,Colorscheme * :hi IndentGuidesEven guibg=#262626 ctermbg=235 "235
nnoremap <F10> :IndentGuidesToggle<CR>
""""""""""" vim-plugins
" Plugin 'WolfgangMehner/vim-plugins'
""""""""""" vim-tmux-navigator
Plugin 'christoomey/vim-tmux-navigator'
let g:tmux_navigator_no_mappings = 1
nnoremap <silent> <c-h> :TmuxNavigateLeft<cr>
nnoremap <silent> <c-j> :TmuxNavigateDown<cr>
nnoremap <silent> <c-k> :TmuxNavigateUp<cr>
nnoremap <silent> <c-l> :TmuxNavigateRight<cr>
nnoremap <silent> <c-\> :TmuxNavigatePrevious<cr>
""""""""""" YouCompleteMe
"Plugin 'Valloric/YouCompleteMe'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
"""""""""""""""""""""""""""""""""" Custom Config """"""""""""""""""""""""""""""""""
syntax enable " 开启语法高亮功能
syntax on " 允许用指定语法高亮配色方案替换默认方案
filetype on
filetype plugin on
filetype indent on
colorscheme solarized
set background=dark
set mouse=
set history=50 " 保留历史命令个数
set number " 显示行号
set cursorline " 突出显示当前行
set autochdir " 自动切换当前目录为当前文件所在的目录
set showcmd " 显示命令
set expandtab " 空格替换TAB
set shiftwidth=4 " 缩进空格数
set tabstop=4 " 硬TAB
set softtabstop=4 " 软TAB
set smarttab " 智能TAB
set shiftwidth=4 " 设定 << 和 >> 命令移动时的宽度为 4
set autoindent " 自动缩进
set cindent
set smartindent
set wrap " 自动换行
set ignorecase " 搜索时忽略大小写
set smartcase
set hlsearch
set incsearch
set nolazyredraw " Don't redraw while executing macros
set magic " Set magic on, for regular expressions
set showmatch " 插入括号时,短暂地跳转到匹配的对应括号
set matchtime=2 " 匹配括号高亮的时间(单位是十分之一秒)
set scrolloff=8 " 光标上下两侧最少保留的屏幕行数
set sidescrolloff=8 " 如果设置 'nowrap',光标左右两侧保留的最少屏幕列数
set ambiwidth=double " 防止特殊符号无法正常显示。
set fileformat=unix " 设置<EOL>格式
set fileformats=unix,dos,mac " 设置<EOL>格式
set encoding=utf8
set fileencoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8,gbk,gb2312,cp936,usc-bom,euc-jp,gb18030
let mapleader = "\<Space>"
" 常见快捷键
nnoremap <Leader>w :w<CR>
" insert模式下光标移动快捷键
inoremap <C-b> <Left>
inoremap <C-j> <Down>
inoremap <C-k> <Up>
inoremap <C-l> <Right>
inoremap <C-a> <Home>
inoremap <C-e> <End>
" insert模式下使用backspace
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
" No sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
" Turn off backups and undo
set nobackup
set nowb
set noswapfile
" 记住上次编辑的位置
autocmd BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("normal '\"")|else|exe "normal $"|endif|endif
"vim -b : 用xxd格式编辑二进制文件
augroup Binary
autocmd!
autocmd BufReadPre *.bin,*.o,*.so,*.a let &bin=1
autocmd BufReadPost *.bin,*.o,*.so,*.a if &bin | %!xxd
autocmd BufReadPost *.bin,*.o,*.so,*.a set ft=xxd | endif
autocmd BufWritePre *.bin,*.o,*.so,*.a if &bin | %!xxd -r
autocmd BufWritePre *.bin,*.o,*.so,*.a endif
autocmd BufWritePost *.bin,*.o,*.so,*.a if &bin | %!xxd
autocmd BufWritePost *.bin,*.o,*.so,*.a set nomod | endif
augroup End