-
Notifications
You must be signed in to change notification settings - Fork 0
/
_vimrc
291 lines (242 loc) · 9.26 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
" -----------------------------------------------------------------------------
" < 判断操作系统是否是 Windows 还是 Linux >
" -----------------------------------------------------------------------------
let g:iswindows = 0
let g:islinux = 0
if(has("win32") || has("win64") || has("win95") || has("win16"))
let g:iswindows = 1
else
let g:islinux = 1
endif
" -----------------------------------------------------------------------------
" < 判断是终端还是 Gvim >
" -----------------------------------------------------------------------------
if has("gui_running")
let g:isGUI = 1
else
let g:isGUI = 0
endif
"==========================常规设置=============================
set nocompatible
set fileencoding=utf-8 "设置当前文件编码
set fileencodings=utf-8,gb2312,gbk,gb18030 "设置支持打开的文件的编码
set termencoding=utf-8
set fileformat=unix
set fileformats=unix,dos
set encoding=utf-8
set langmenu=zh_CN.UTF-8
language message zh_CN.UTF-8
if (g:iswindows && g:isGUI)
"解决菜单乱码
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
"解决consle输出乱码
language messages zh_CN.utf-8
endif
set nu!
filetype off
"set guifont=Consolas:h13
set guifont=Consolas\ for\ Powerline\ FixedD:h13
set tags=tags;
set autochdir
set hidden
set laststatus=2 " 启动显示状态行(1),总是显示状态行(2)
set number " 显示行号
set expandtab " 是否在缩进和遇到Tab键时使用空格代替; 使用noexpandtab取消设置
set autoindent " 自动缩进
set cindent
set confirm
set smartindent "启用智能对齐方式
set softtabstop=4
set tabstop=4 "设置Tab键的宽度,可以更改,如:宽度为2
set shiftwidth=4 "换行时自动缩进宽度,可更改(宽度同tabstop)
set smarttab "指定按一次backspace就删除shiftwidth宽度
set foldenable "启用折叠
set foldmethod=manual "marker 自动折叠方式 indent 折叠方式 manual 手动折叠
" 常规模式下用空格键来开关光标行所在折叠(注:zR 展开所有折叠,zM 关闭所有折叠)
nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>
set autoread "当文件在外部被修改,自动更新该文件
set ignorecase "搜索模式里忽略大小写
set smartcase "如果搜索模式包含大写字符,不使用 'ignorecase' 选项,只有在输入搜索模式并且打开
set showcmd "在状态栏显示当前输入的命令
set showmode "显示INSERT NORMAL等
set hlsearch
set incsearch
set paste " 支持外部复制(好像不管用)
set clipboard+=unnamed " 与windows共享剪贴板
set history=99 " keep 99 lines of command history
set showmatch " 显示括号配对情况
" 显示/隐藏菜单栏、工具栏、滚动条,可用 Ctrl + F11 切换
if g:isGUI
set guioptions-=m
set guioptions-=T
set guioptions-=r
set guioptions-=L
nmap <silent> <c-F11> :if &guioptions =~# 'm' <Bar>
\set guioptions-=m <Bar>
\set guioptions-=T <Bar>
\set guioptions-=r <Bar>
\set guioptions-=L <Bar>
\else <Bar>
\set guioptions+=m <Bar>
\set guioptions+=T <Bar>
\set guioptions+=r <Bar>
\set guioptions+=L <Bar>
\endif<CR>
endif
set shortmess=atI " 去掉启动欢迎界面
set completeopt=preview,menu
set ruler
set cursorline
set autowrite
set magic
set nowrap
set linebreak
set iskeyword+=_,$,@,%,#,-
set backspace=indent,eol,start
set undofile
set mouse=a
set selection=exclusive
set selectmode=mouse,key
" 禁止生成临时文件
set nobackup
set noswapfile
" if has("persistent_undo")
" set undodir = ~/.undodir/
" endif
"autocmd GUIEnter * simalt ~x " windows下启动vim最大化
winpos 100 10
set lines=45 columns=150
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
"使用自带补全功能
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascrīpt set omnifunc=javascrīptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#Complete
"=============================插件安装和设置=================================
set rtp+=$VIM/vimfiles/bundle/Vundle.vim/
call vundle#begin('$VIM/vimfiles/bundle/')
"let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
""""""""vim scripts""""""""""""""""""
Bundle 'winmanager'
""""""""git上的插件"""""""""""""""
Bundle 'scrooloose/nerdtree'
Bundle 'bufexplorer'
"Bundle 'taglist'
Bundle 'majutsushi/tagbar'
Bundle 'vim-airline'
Bundle 'jiangmiao/auto-pairs'
Bundle 'mattn/emmet-vim'
Bundle 'javacomplete'
Bundle 'flazz/vim-colorschemes'
call vundle#end()
filetype on "启用文件类型侦测
filetype plugin on "针对不同的文件类型加载对应的插件
filetype plugin indent on "启用缩进
syntax enable
syntax on
" 设置winmanager
" 设置界面分割
let g:winManagerWindowLayout = "FileExplorer"
"设置winmanager的宽度,默认为25
let g:winManagerWidth = 30
"定义打开关闭winmanager快捷键为F8
nmap <silent> <F8> :WMToggle<cr>
"在进入vim时自动打开winmanager
let g:AutoOpenWinManager = 1
" Tagbar配置
nmap <silent> <F4> :TagbarToggle<CR>
let g:tagbar_ctags_bin = 'ctags'
let g:tagbar_width = 30
" TagList 插件配置
"nmap tl :TagbarClose<CR>:Tlist<CR>
"let Tlist_Auto_Open=1
"let Tlist_Show_One_File=1 "只显示当前文件的tags
"let Tlist_Enable_Fold_Column=0 "使taglist插件不显示左边的折叠行
"let Tlist_Exit_OnlyWindow=1 "如果Taglist窗口是最后一个窗口则退出Vim
"let Tlist_File_Fold_Auto_Close=1 "自动折叠
"let Tlist_WinWidth=30 "设置窗口宽度
"let Tlist_Use_Right_Window=1 "在右侧窗口中显示
" NERDTree plugin
map <F2> :NERDTreeMirror<CR>
map <F3> :NERDTreeToggle<CR>
" 设置主题
colorscheme freya
let g:airline_theme="luna"
"let g:airline_theme="solarized"
"let g:airline_theme="tomorrow"
"let g:airline_theme="base16"
"let g:airline_theme="lucius"
"let g:airline_theme="powerlineish"
"let g:airline_theme="molokai"
"let g:airline_theme="wombat"
"let g:airline_theme="sol"
"let g:airline_theme="murmur"
"let g:airline_theme="ubaryd"
"let g:airline_theme="badwolf"
"let g:airline_theme="bubblegum"
"let g:airline_theme="dark"
"let g:airline_theme="durant"
"let g:airline_theme="hybrid"
"let g:airline_theme="jellybeans"
"let g:airline_theme="kalisi"
"let g:airline_theme="laederon"
"let g:airline_theme="light"
"let g:airline_theme="monochrome"
"let g:airline_theme="raven"
"let g:airline_theme="serene"
"let g:airline_theme="silver"
"let g:airline_theme="simple"
"let g:airline_theme="raven"
"let g:airline_theme="understated"
"let g:airline_theme="zenburn"
let g:airline_section_b = '%{strftime("%c")}'
"这个是安装字体后 必须设置此项"
let g:airline_powerline_fonts = 1
"打开tabline功能,方便查看Buffer和切换,这个功能比较不错"
"我还省去了minibufexpl插件,因为我习惯在1个Tab下用多个buffer"
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#buffer_nr_show = 1
"设置切换Buffer快捷键"
nnoremap <C-Q> :bn<CR>
nnoremap <C-P> :bp<CR>
" 关闭状态显示空白符号计数,这个对我用处不大"
let g:airline#extensions#whitespace#enabled = 0
let g:airline#extensions#whitespace#symbol = '!'
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
" 箭头图标的显示
" old vim-powerline symbols
let g:airline_left_sep = '⮀'
let g:airline_left_alt_sep = '⮁'
let g:airline_right_sep = '⮂'
let g:airline_right_alt_sep = '⮃'
let g:airline_symbols.branch = '⭠'
let g:airline_symbols.readonly = '⭤'
let g:airline_symbols.linenr = '⭡'
" emmet配置
let g:user_emmet_install_global = 0
let g:user_emmet_settings = {
\'html' : {
\ 'indent_blockelement': 1
\}
\}
autocmd FileType html,css,sass,scss,less,php EmmetInstall
"javacomplete配置
setlocal omnifunc=javacomplete#Complete
autocmd FileType java set omnifunc=javacomplete#Complete
autocmd FileType java set completefunc=javacomplete#CompleteParamsInf
autocmd FileType java inoremap
setlocal omnifunc=javacomplete#Complete
autocmd Filetype java set omnifunc=javacomplete#Complete
autocmd Filetype java set completefunc=javacomplete#CompleteParamsInf
inoremap <buffer> <C-X><C-U> <C-X><C-U><C-P>
inoremap <buffer> <C-S-Space> <C-X><C-U><C-P>
autocmd Filetype java,JavaScript,jsp inoremap <buffer> . .<C-X><C-O><C-P>