-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_vimrc
326 lines (261 loc) · 8.51 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
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
"设置工作目录为当前编辑文件的目录
set bsdir=buffer
set autochdir
"编码设置
set enc=utf-8
set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936
"语言设置
set langmenu=zh_CN.UTF-8
language message zh_CN.UTF-8
"set guifont=Inconsolata-dz_for_Powerline:h12
set guifont=DejaVu_Sans_Mono_for_Powerline:h12
"set guifont=Monaco:h12
set gfw=YaHei\ Consolas\ Hybrid:h12
set gfw=Aeteye:h12
set helplang=cn
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
"禁止生成临时文件
set nobackup
set nowritebackup
"搜索忽略大小写
set ignorecase
"搜索逐字符高亮
set incsearch
"行内替换
set gdefault
"始终显示行号
set nu!
"显示光标的坐标
set ruler
"高亮整行
set cursorline
"自动缩进
set noautoindent
set cindent
set smartindent
"Tab键的宽度
set shiftwidth=4
set tabstop=4
"使用4个空格代替Tab
set expandtab
set softtabstop=4
"Tab键插入四个空格,仅PHP
autocmd FileType php set shiftwidth=4 tabstop=4 expandtab softtabstop=4
"输入法设置
if has('multi_byte_ime')
"未开启IME时光标背景色
hi Cursor guifg=bg guibg=Orange gui=NONE
"开启IME时光标背景色
hi CursorIM guifg=NONE guibg=Skyblue gui=NONE
" 关闭Vim的自动切换IME输入法(插入模式和检索模式)
set iminsert=0 imsearch=0
" 插入模式输入法状态未被记录时,默认关闭IME
"inoremap <silent> <ESC> <ESC>:set iminsert=0<CR>
endif
"与Windows共享剪贴板
set clipboard+=unnamed
"编辑vimrc之后,重新加载
autocmd! bufwritepost _vimrc source $VIM/_vimrc
"配色方案
syntax enable
set background=dark
"colorscheme solarized
""" color scheme
set t_Co=256
colo molokai
" hilight function name
autocmd BufNewFile,BufRead * :syntax match cfunctions "\<[a-zA-Z_][a-zA-Z_0-9]*\>[^()]*)("me=e-2
autocmd BufNewFile,BufRead * :syntax match cfunctions "\<[a-zA-Z_][a-zA-Z_0-9]*\>\s*("me=e-1
hi cfunctions ctermfg=81
hi Type ctermfg=118 cterm=none
hi Structure ctermfg=118 cterm=none
hi Macro ctermfg=161 cterm=bold
hi PreCondit ctermfg=161 cterm=bold
set cursorline
"hi CursorLine cterm=underline
""" color scheme
"##########插件管理 开始#############
filetype off
"自动安装
let iCanHazVundle=1
let vundle_readme=expand('~/.vim/bundle/vundle/README.md')
if !filereadable(vundle_readme)
echo "Installing Vundle.."
echo ""
silent !mkdir -p ~/.vim/bundle
silent !git clone https://github.com/gmarik/vundle ~/.vim/bundle/vundle
let iCanHazVundle=0
endif
"根据不同os来更改plugin的路径
if has('win32') || has('win64')
set rtp+=$VIM/vimfiles/bundle/vundle/
call vundle#rc('$VIM/vimfiles/bundle/')
else
" Usual quickstart instructions
set rtp+=~/.vim/vundle/
call vundle#rc()
endif
"插件管理核心库
Bundle 'gmarik/vundle'
"代码补全
Bundle 'Shougo/neocomplcache'
"Bundle 'Shougo/neosnippet'
"代码段自动生成
"Bundle 'snipMate'
"快速查找
Bundle 'kien/ctrlp.vim'
Bundle "MarcWeber/vim-addon-mw-utils"
Bundle "tomtom/tlib_vim"
"Bundle "snipmate-snippets"
"Bundle "garbas/vim-snipmate"
"插件 语法/高亮
Bundle 'JavaScript-syntax'
Bundle 'jQuery'
Bundle 'othree/html5.vim'
Bundle 'groenewege/vim-less'
"Bundle 'Markdown'
"Bundle 'Markdown-syntax'
"Bundle 'plasticboy/vim-markdown'
Bundle 'php.vim-html-enhanced'
"HTML混排缩进改善
Bundle "pangloss/vim-javascript"
"按特殊字符对其, 需要修改源码以支持中文字符 https://github.com/muzuiget/hacking-patches/blob/master/tabular_cjk_width.patch
Bundle 'Tabular'
"statuslines 增强
"Bundle 'scrooloose/vim-statline'
"""""""""""""""""""""""""""""""""
" => airline
"""""""""""""""""""""""""""""""""
Bundle 'bling/vim-airline'
set laststatus=2
let g:airline_detect_whitespace = 0 "关闭空白符检测
let g:airline_theme = "powerlineish" "设定主题
"let g:airline_theme = 'luna'
"let g:airline_theme = 'badwolf'
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#enabled = 1 "顶部tab栏显示
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
let g:airline_enable_branch=1
let g:airline_enable_syntastic=1
let g:airline_detect_paste=1
"""""""""""""""""""""""""""""""""
" => 文件管理器
"""""""""""""""""""""""""""""""""
Bundle 'scrooloose/nerdtree'
"autocmd vimenter * NERDTree
"在()、""、甚至HTML标签之间快速跳转;
Bundle 'matchit.zip'
"显示行末的空格;
Bundle 'ShowTrailingWhitespace'
"JS代码格式化插件;
Bundle '_jsbeautify'
Bundle 'stephpy/vim-php-cs-fixer'
Bundle 'jcf/vim-latex'
Bundle 'thinca/vim-quickrun'
Bundle 'mattn/webapi-vim'
Bundle 'tyru/open-browser.vim'
Bundle 'superbrothers/vim-quickrun-markdown-gfm'
"python
Bundle 'klen/python-mode'
"代码折叠起始的层数
set foldlevelstart=10
"Bundle 'hallettj/jslint.vim'
"即时预览CSS颜色
"Bundle 'skammer/vim-css-color'
"Bundle 'ZenCoding.vim'
"Bundle 'The-NERD-tree'
"Bundle 'SuperTab'
"语法检查
"Bundle 'scrooloose/syntastic'
"颜色管理
Bundle 'altercation/vim-colors-solarized'
"激活插件与文件类型的依赖关系
filetype plugin indent on
"##########插件管理 结束#############
"自定义关联文件类型
au BufNewFile,BufRead *.less set filetype=css
au BufNewFile,BufRead *.phtml set filetype=php
au BufRead,BufNewFile *.js set ft=javascript.jquery
"--------插件设置
"---NeoComplCache 启动并使用Tab触发
let g:neocomplcache_enable_at_startup = 1
" Use smartcase.
let g:neocomplcache_enable_smart_case = 1
" Use camel case completion.
let g:neocomplcache_enable_camel_case_completion = 1
" Use underbar completion.
let g:neocomplcache_enable_underbar_completion = 1
" Set minimum syntax keyword length.
let g:neocomplcache_min_syntax_length = 2
let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*'
" Define keyword.
if !exists('g:neocomplcache_keyword_patterns')
let g:neocomplcache_keyword_patterns = {}
endif
let g:neocomplcache_keyword_patterns['default'] = '\h\w*'
" AutoComplPop like behavior.
let g:neocomplcache_enable_auto_select = 1
" Plugin key-mappings.
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
" SuperTab like snippets behavior.
"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
autocmd FileType php,phtml setlocal omnifunc=phpcomplete#CompletePHP
autocmd FileType css,less setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
" vim markdown
let g:vim_markdown_folding_disabled=1
" ctrlp
noremap <C-W><C-U> :CtrlPMRU<CR>
nnoremap <C-W>u :CtrlPMRU<CR>
let g:ctrlp_custom_ignore = '\.git$\|\.hg$\|\.svn$\|.rvm$'
let g:ctrlp_working_path_mode=0
let g:ctrlp_match_window_bottom=1
let g:ctrlp_max_height=15
let g:ctrlp_match_window_reversed=0
let g:ctrlp_mruf_max=500
let g:ctrlp_follow_symlinks=1
let g:quickrun_config = {
\ 'markdown': {
\ 'type': 'markdown/gfm',
\ 'outputter': 'browser'
\ }
\ }
"--------自定义快捷键
"PHP code fix
"let g:php_cs_fixer_path = "D:\xampp\php\php-cs-fixer.phar" " define the path to the php-cs-fixer.phar
let g:php_cs_fixer_level = "all" " which level ?
"let g:php_cs_fixer_config = "default" " configuration
"let g:php_cs_fixer_php_path = "php" " Path to PHP
"let g:php_cs_fixer_fixers_list = "" " List of fixers
"let g:php_cs_fixer_enable_default_mapping = 1 " Enable the mapping by default (<leader>pcd)
"let g:php_cs_fixer_dry_run = 0 " Call command with dry-run option
"let g:php_cs_fixer_verbose = 0 " Return the output of command if 1, else an inline information.
" 编辑模式进行光标移动
inoremap <C-h> <left>
inoremap <C-l> <right>
inoremap <C-j> <C-o>gj
inoremap <C-k> <C-o>gk
"A-t : 打开NERDTree
map <silent> <C-t> <ESC>:NERDTree<CR>
" 以打开NERDTree时的目录为工作目录
let NERDTreeChDirMode=1
"mm : 规范行首空格<cr>去除多余字符<cr>删除空白行<cr>规范行数
nmap mm :%s/\r//g<cr>
"ff : 前后补全
"vmap ff <Esc>`>i')?><Esc>`<i<?=$this->_('<Esc>
vmap ff "zdi<?=$this->_('<C-R>z');?><ESC>