1.安裝vundle管理插件javascript
sudo apt-get install vim sudo apt-get install gvim sudo apt-get install git mkdir .vim cd .vim mkdir bundle cd bundle git clone https://github.com/gmarik/vundle.git
2.gvim配置文件php
1 " ============================================================================= 2 " << 判斷操做系統是 Windows 仍是 Linux 和判斷是終端仍是 Gvim >> 3 " ============================================================================= 4 5 " ----------------------------------------------------------------------------- 6 " < 判斷操做系統是不是 Windows 仍是 Linux > 7 " ----------------------------------------------------------------------------- 8 let g:iswindows = 0 9 let g:islinux = 0 10 if(has("win32") || has("win64") || has("win95") || has("win16")) 11 let g:iswindows = 1 12 else 13 let g:islinux = 1 14 endif 15 16 " ----------------------------------------------------------------------------- 17 " < 判斷是終端仍是 Gvim > 18 " ----------------------------------------------------------------------------- 19 if has("gui_running") 20 let g:isGUI = 1 21 else 22 let g:isGUI = 0 23 endif 24 25 26 " ============================================================================= 27 " << 如下爲軟件默認配置 >> 28 " ============================================================================= 29 30 " ----------------------------------------------------------------------------- 31 " < Windows Gvim 默認配置> 作了一點修改 32 " ----------------------------------------------------------------------------- 33 if (g:iswindows && g:isGUI) 34 source $VIMRUNTIME/vimrc_example.vim 35 source $VIMRUNTIME/mswin.vim 36 behave mswin 37 set diffexpr=MyDiff() 38 39 function MyDiff() 40 let opt = '-a --binary ' 41 if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif 42 if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif 43 let arg1 = v:fname_in 44 if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif 45 let arg2 = v:fname_new 46 if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif 47 let arg3 = v:fname_out 48 if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif 49 let eq = '' 50 if $VIMRUNTIME =~ ' ' 51 if &sh =~ '\<cmd' 52 let cmd = '""' . $VIMRUNTIME . '\diff"' 53 let eq = '"' 54 else 55 let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"' 56 endif 57 else 58 let cmd = $VIMRUNTIME . '\diff' 59 endif 60 silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq 61 endfunction 62 endif 63 64 " ----------------------------------------------------------------------------- 65 " < Linux Gvim/Vim 默認配置> 作了一點修改 66 " ----------------------------------------------------------------------------- 67 if g:islinux 68 set hlsearch "高亮搜索 69 set incsearch "在輸入要搜索的文字時,實時匹配 70 71 " Uncomment the following to have Vim jump to the last position when 72 " reopening a file 73 if has("autocmd") 74 au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif 75 endif 76 77 if g:isGUI 78 " Source a global configuration file if available 79 if filereadable("/etc/vim/gvimrc.local") 80 source /etc/vim/gvimrc.local 81 endif 82 else 83 " This line should not be removed as it ensures that various options are 84 " properly set to work with the Vim-related packages available in Debian. 85 runtime! debian.vim 86 87 " Vim5 and later versions support syntax highlighting. Uncommenting the next 88 " line enables syntax highlighting by default. 89 if has("syntax") 90 syntax on 91 endif 92 93 set mouse=a " 在任何模式下啓用鼠標 94 set t_Co=256 " 在終端啓用256色 95 set backspace=2 " 設置退格鍵可用 96 97 " Source a global configuration file if available 98 if filereadable("/etc/vim/vimrc.local") 99 source /etc/vim/vimrc.local 100 endif 101 endif 102 endif 103 104 105 " ============================================================================= 106 " << 如下爲用戶自定義配置 >> 107 " ============================================================================= 108 109 " ----------------------------------------------------------------------------- 110 " < Vundle 插件管理工具配置 > 111 " ----------------------------------------------------------------------------- 112 " 用於更方便的管理vim插件,具體用法參考 :h vundle 幫助 113 " Vundle工具安裝方法爲在終端輸入以下命令 114 " git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle 115 " 若是想在 windows 安裝就必需先安裝 "git for window",可查閱網上資料 116 117 set nocompatible "禁用 Vi 兼容模式 118 filetype off "禁用文件類型偵測 119 120 if g:islinux 121 set rtp+=~/.vim/bundle/vundle/ 122 call vundle#rc() 123 else 124 set rtp+=$VIM/vimfiles/bundle/vundle/ 125 call vundle#rc('$VIM/vimfiles/bundle/') 126 endif 127 128 " 使用Vundle來管理插件,這個必需要有。 129 Bundle 'gmarik/vundle' 130 131 " 如下爲要安裝或更新的插件,不一樣倉庫都有(具體書寫規範請參考幫助) 132 Bundle 'a.vim' 133 Bundle 'Align' 134 Bundle 'jiangmiao/auto-pairs' 135 Bundle 'bufexplorer.zip' 136 Bundle 'ccvext.vim' 137 Bundle 'cSyntaxAfter' 138 Bundle 'ctrlpvim/ctrlp.vim' 139 Bundle 'mattn/emmet-vim' 140 Bundle 'Yggdroot/indentLine' 141 Bundle 'vim-javacompleteex' 142 Bundle 'Mark--Karkat' 143 Bundle 'Shougo/neocomplcache.vim' 144 Bundle 'scrooloose/nerdcommenter' 145 Bundle 'scrooloose/nerdtree' 146 Bundle 'OmniCppComplete' 147 Bundle 'Lokaltog/vim-powerline' 148 Bundle 'repeat.vim' 149 Bundle 'msanders/snipmate.vim' 150 Bundle 'wesleyche/SrcExpl' 151 Bundle 'std_c.zip' 152 Bundle 'tpope/vim-surround' 153 Bundle 'scrooloose/syntastic' 154 Bundle 'majutsushi/tagbar' 155 Bundle 'taglist.vim' 156 Bundle 'TxtBrowser' 157 Bundle 'ZoomWin' 158 159 " ----------------------------------------------------------------------------- 160 " < 編碼配置 > 161 " ----------------------------------------------------------------------------- 162 " 注:使用utf-8格式後,軟件與程序源碼、文件路徑不能有中文,不然報錯 163 set encoding=utf-8 "設置gvim內部編碼,默認不更改 164 set fileencoding=utf-8 "設置當前文件編碼,能夠更改,如:gbk(同cp936) 165 set fileencodings=ucs-bom,utf-8,gbk,cp936,latin-1 "設置支持打開的文件的編碼 166 167 " 文件格式,默認 ffs=dos,unix 168 set fileformat=unix "設置新(當前)文件的<EOL>格式,能夠更改,如:dos(windows系統經常使用) 169 set fileformats=unix,dos,mac "給出文件的<EOL>格式類型 170 171 if (g:iswindows && g:isGUI) 172 "解決菜單亂碼 173 source $VIMRUNTIME/delmenu.vim 174 source $VIMRUNTIME/menu.vim 175 176 "解決consle輸出亂碼 177 language messages zh_CN.utf-8 178 endif 179 180 " ----------------------------------------------------------------------------- 181 " < 編寫文件時的配置 > 182 " ----------------------------------------------------------------------------- 183 filetype on "啓用文件類型偵測 184 filetype plugin on "針對不一樣的文件類型加載對應的插件 185 filetype plugin indent on "啓用縮進 186 set smartindent "啓用智能對齊方式 187 set expandtab "將Tab鍵轉換爲空格 188 set tabstop=4 "設置Tab鍵的寬度,能夠更改,如:寬度爲2 189 set shiftwidth=4 "換行時自動縮進寬度,可更改(寬度同tabstop) 190 set smarttab "指定按一次backspace就刪除shiftwidth寬度 191 set foldenable "啓用摺疊 192 set foldmethod=indent "indent 摺疊方式 193 " set foldmethod=marker "marker 摺疊方式 194 195 " 常規模式下用空格鍵來開關光標行所在摺疊(注:zR 展開全部摺疊,zM 關閉全部摺疊) 196 nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR> 197 198 " 當文件在外部被修改,自動更新該文件 199 set autoread 200 201 " 常規模式下輸入 cS 清除行尾空格 202 nmap cS :%s/\s\+$//g<CR>:noh<CR> 203 204 " 常規模式下輸入 cM 清除行尾 ^M 符號 205 nmap cM :%s/\r$//g<CR>:noh<CR> 206 207 set ignorecase "搜索模式裏忽略大小寫 208 set smartcase "若是搜索模式包含大寫字符,不使用 'ignorecase' 選項,只有在輸入搜索模式而且打開 'ignorecase' 選項時纔會使用 209 " set noincsearch "在輸入要搜索的文字時,取消實時匹配 210 211 " Ctrl + K 插入模式下光標向上移動 212 imap <c-k> <Up> 213 214 " Ctrl + J 插入模式下光標向下移動 215 imap <c-j> <Down> 216 217 " Ctrl + H 插入模式下光標向左移動 218 imap <c-h> <Left> 219 220 " Ctrl + L 插入模式下光標向右移動 221 imap <c-l> <Right> 222 223 " 啓用每行超過80列的字符提示(字體變藍並加下劃線),不啓用就註釋掉 224 au BufWinEnter * let w:m2=matchadd('Underlined', '\%>' . 80 . 'v.\+', -1) 225 226 " ----------------------------------------------------------------------------- 227 " < 界面配置 > 228 " ----------------------------------------------------------------------------- 229 set number "顯示行號 230 set laststatus=2 "啓用狀態欄信息 231 set cmdheight=2 "設置命令行的高度爲2,默認爲1 232 set cursorline "突出顯示當前行 233 " set guifont=YaHei_Consolas_Hybrid:h10 "設置字體:字號(字體名稱空格用下劃線代替) 234 set nowrap "設置不自動換行 235 set shortmess=atI "去掉歡迎界面 236 237 " 設置 gVim 窗口初始位置及大小 238 if g:isGUI 239 " au GUIEnter * simalt ~x "窗口啓動時自動最大化 240 winpos 100 10 "指定窗口出現的位置,座標原點在屏幕左上角 241 set lines=38 columns=120 "指定窗口大小,lines爲高度,columns爲寬度 242 endif 243 244 " 設置代碼配色方案 245 if g:isGUI 246 colorscheme elflord "Gvim配色方案 247 else 248 colorscheme elflord "終端配色方案 249 endif 250 251 " 顯示/隱藏菜單欄、工具欄、滾動條,可用 Ctrl + F11 切換 252 if g:isGUI 253 set guioptions-=m 254 set guioptions-=T 255 set guioptions-=r 256 set guioptions-=L 257 nmap <silent> <c-F11> :if &guioptions =~# 'm' <Bar> 258 \set guioptions-=m <Bar> 259 \set guioptions-=T <Bar> 260 \set guioptions-=r <Bar> 261 \set guioptions-=L <Bar> 262 \else <Bar> 263 \set guioptions+=m <Bar> 264 \set guioptions+=T <Bar> 265 \set guioptions+=r <Bar> 266 \set guioptions+=L <Bar> 267 \endif<CR> 268 endif 269 270 " ----------------------------------------------------------------------------- 271 " < 編譯、鏈接、運行配置 (目前只配置了C、C++、Java語言)> 272 " ----------------------------------------------------------------------------- 273 " F9 一鍵保存、編譯、鏈接存並運行 274 nmap <F9> :call Run()<CR> 275 imap <F9> <ESC>:call Run()<CR> 276 277 " Ctrl + F9 一鍵保存並編譯 278 nmap <c-F9> :call Compile()<CR> 279 imap <c-F9> <ESC>:call Compile()<CR> 280 281 " Ctrl + F10 一鍵保存並鏈接 282 nmap <c-F10> :call Link()<CR> 283 imap <c-F10> <ESC>:call Link()<CR> 284 285 let s:LastShellReturn_C = 0 286 let s:LastShellReturn_L = 0 287 let s:ShowWarning = 1 288 let s:Obj_Extension = '.o' 289 let s:Exe_Extension = '.exe' 290 let s:Class_Extension = '.class' 291 let s:Sou_Error = 0 292 293 let s:windows_CFlags = 'gcc\ -fexec-charset=gbk\ -Wall\ -g\ -O0\ -c\ %\ -o\ %<.o' 294 let s:linux_CFlags = 'gcc\ -Wall\ -g\ -O0\ -c\ %\ -o\ %<.o' 295 296 let s:windows_CPPFlags = 'g++\ -fexec-charset=gbk\ -Wall\ -g\ -O0\ -c\ %\ -o\ %<.o' 297 let s:linux_CPPFlags = 'g++\ -Wall\ -g\ -O0\ -c\ %\ -o\ %<.o' 298 299 let s:JavaFlags = 'javac\ %' 300 301 func! Compile() 302 exe ":ccl" 303 exe ":update" 304 let s:Sou_Error = 0 305 let s:LastShellReturn_C = 0 306 let Sou = expand("%:p") 307 let v:statusmsg = '' 308 if expand("%:e") == "c" || expand("%:e") == "cpp" || expand("%:e") == "cxx" 309 let Obj = expand("%:p:r").s:Obj_Extension 310 let Obj_Name = expand("%:p:t:r").s:Obj_Extension 311 if !filereadable(Obj) || (filereadable(Obj) && (getftime(Obj) < getftime(Sou))) 312 redraw! 313 if expand("%:e") == "c" 314 if g:iswindows 315 exe ":setlocal makeprg=".s:windows_CFlags 316 else 317 exe ":setlocal makeprg=".s:linux_CFlags 318 endif 319 echohl WarningMsg | echo " compiling..." 320 silent make 321 elseif expand("%:e") == "cpp" || expand("%:e") == "cxx" 322 if g:iswindows 323 exe ":setlocal makeprg=".s:windows_CPPFlags 324 else 325 exe ":setlocal makeprg=".s:linux_CPPFlags 326 endif 327 echohl WarningMsg | echo " compiling..." 328 silent make 329 endif 330 redraw! 331 if v:shell_error != 0 332 let s:LastShellReturn_C = v:shell_error 333 endif 334 if g:iswindows 335 if s:LastShellReturn_C != 0 336 exe ":bo cope" 337 echohl WarningMsg | echo " compilation failed" 338 else 339 if s:ShowWarning 340 exe ":bo cw" 341 endif 342 echohl WarningMsg | echo " compilation successful" 343 endif 344 else 345 if empty(v:statusmsg) 346 echohl WarningMsg | echo " compilation successful" 347 else 348 exe ":bo cope" 349 endif 350 endif 351 else 352 echohl WarningMsg | echo ""Obj_Name"is up to date" 353 endif 354 elseif expand("%:e") == "java" 355 let class = expand("%:p:r").s:Class_Extension 356 let class_Name = expand("%:p:t:r").s:Class_Extension 357 if !filereadable(class) || (filereadable(class) && (getftime(class) < getftime(Sou))) 358 redraw! 359 exe ":setlocal makeprg=".s:JavaFlags 360 echohl WarningMsg | echo " compiling..." 361 silent make 362 redraw! 363 if v:shell_error != 0 364 let s:LastShellReturn_C = v:shell_error 365 endif 366 if g:iswindows 367 if s:LastShellReturn_C != 0 368 exe ":bo cope" 369 echohl WarningMsg | echo " compilation failed" 370 else 371 if s:ShowWarning 372 exe ":bo cw" 373 endif 374 echohl WarningMsg | echo " compilation successful" 375 endif 376 else 377 if empty(v:statusmsg) 378 echohl WarningMsg | echo " compilation successful" 379 else 380 exe ":bo cope" 381 endif 382 endif 383 else 384 echohl WarningMsg | echo ""class_Name"is up to date" 385 endif 386 else 387 let s:Sou_Error = 1 388 echohl WarningMsg | echo " please choose the correct source file" 389 endif 390 exe ":setlocal makeprg=make" 391 endfunc 392 393 func! Link() 394 call Compile() 395 if s:Sou_Error || s:LastShellReturn_C != 0 396 return 397 endif 398 if expand("%:e") == "c" || expand("%:e") == "cpp" || expand("%:e") == "cxx" 399 let s:LastShellReturn_L = 0 400 let Sou = expand("%:p") 401 let Obj = expand("%:p:r").s:Obj_Extension 402 if g:iswindows 403 let Exe = expand("%:p:r").s:Exe_Extension 404 let Exe_Name = expand("%:p:t:r").s:Exe_Extension 405 else 406 let Exe = expand("%:p:r") 407 let Exe_Name = expand("%:p:t:r") 408 endif 409 let v:statusmsg = '' 410 if filereadable(Obj) && (getftime(Obj) >= getftime(Sou)) 411 redraw! 412 if !executable(Exe) || (executable(Exe) && getftime(Exe) < getftime(Obj)) 413 if expand("%:e") == "c" 414 setlocal makeprg=gcc\ -o\ %<\ %<.o 415 echohl WarningMsg | echo " linking..." 416 silent make 417 elseif expand("%:e") == "cpp" || expand("%:e") == "cxx" 418 setlocal makeprg=g++\ -o\ %<\ %<.o 419 echohl WarningMsg | echo " linking..." 420 silent make 421 endif 422 redraw! 423 if v:shell_error != 0 424 let s:LastShellReturn_L = v:shell_error 425 endif 426 if g:iswindows 427 if s:LastShellReturn_L != 0 428 exe ":bo cope" 429 echohl WarningMsg | echo " linking failed" 430 else 431 if s:ShowWarning 432 exe ":bo cw" 433 endif 434 echohl WarningMsg | echo " linking successful" 435 endif 436 else 437 if empty(v:statusmsg) 438 echohl WarningMsg | echo " linking successful" 439 else 440 exe ":bo cope" 441 endif 442 endif 443 else 444 echohl WarningMsg | echo ""Exe_Name"is up to date" 445 endif 446 endif 447 setlocal makeprg=make 448 elseif expand("%:e") == "java" 449 return 450 endif 451 endfunc 452 453 func! Run() 454 let s:ShowWarning = 0 455 call Link() 456 let s:ShowWarning = 1 457 if s:Sou_Error || s:LastShellReturn_C != 0 || s:LastShellReturn_L != 0 458 return 459 endif 460 let Sou = expand("%:p") 461 if expand("%:e") == "c" || expand("%:e") == "cpp" || expand("%:e") == "cxx" 462 let Obj = expand("%:p:r").s:Obj_Extension 463 if g:iswindows 464 let Exe = expand("%:p:r").s:Exe_Extension 465 else 466 let Exe = expand("%:p:r") 467 endif 468 if executable(Exe) && getftime(Exe) >= getftime(Obj) && getftime(Obj) >= getftime(Sou) 469 redraw! 470 echohl WarningMsg | echo " running..." 471 if g:iswindows 472 exe ":!%<.exe" 473 else 474 if g:isGUI 475 exe ":!gnome-terminal -x bash -c './%<; echo; echo 請按 Enter 鍵繼續; read'" 476 else 477 exe ":!clear; ./%<" 478 endif 479 endif 480 redraw! 481 echohl WarningMsg | echo " running finish" 482 endif 483 elseif expand("%:e") == "java" 484 let class = expand("%:p:r").s:Class_Extension 485 if getftime(class) >= getftime(Sou) 486 redraw! 487 echohl WarningMsg | echo " running..." 488 if g:iswindows 489 exe ":!java %<" 490 else 491 if g:isGUI 492 exe ":!gnome-terminal -x bash -c 'java %<; echo; echo 請按 Enter 鍵繼續; read'" 493 else 494 exe ":!clear; java %<" 495 endif 496 endif 497 redraw! 498 echohl WarningMsg | echo " running finish" 499 endif 500 endif 501 endfunc 502 503 504 " ----------------------------------------------------------------------------- 505 " < 在瀏覽器中預覽 Html 或 PHP 文件 > 506 " ----------------------------------------------------------------------------- 507 " 修改前請先通讀此模塊,明白了再改以免錯誤 508 509 " F5 加瀏覽器名稱縮寫調用瀏覽器預覽,啓用前先肯定有安裝相應瀏覽器,並在下面的配置好其安裝目錄 510 if g:iswindows 511 "如下爲只支持Windows系統的瀏覽器 512 513 " 調用系統IE瀏覽器預覽,若是已卸載可將其註釋 514 nmap <F5>ie :call ViewInBrowser("ie")<cr> 515 imap <F5>ie <ESC>:call ViewInBrowser("ie")<cr> 516 517 " 調用IETester(IE測試工具)預覽,若是有安裝可取消註釋 518 " nmap <F5>ie6 :call ViewInBrowser("ie6")<cr> 519 " imap <F5>ie6 <ESC>:call ViewInBrowser("ie6")<cr> 520 " nmap <F5>ie7 :call ViewInBrowser("ie7")<cr> 521 " imap <F5>ie7 <ESC>:call ViewInBrowser("ie7")<cr> 522 " nmap <F5>ie8 :call ViewInBrowser("ie8")<cr> 523 " imap <F5>ie8 <ESC>:call ViewInBrowser("ie8")<cr> 524 " nmap <F5>ie9 :call ViewInBrowser("ie9")<cr> 525 " imap <F5>ie9 <ESC>:call ViewInBrowser("ie9")<cr> 526 " nmap <F5>ie10 :call ViewInBrowser("ie10")<cr> 527 " imap <F5>ie10 <ESC>:call ViewInBrowser("ie10")<cr> 528 " nmap <F5>iea :call ViewInBrowser("iea")<cr> 529 " imap <F5>iea <ESC>:call ViewInBrowser("iea")<cr> 530 elseif g:islinux 531 "如下爲只支持Linux系統的瀏覽器 532 "暫未配置,待有時間再弄了 533 endif 534 535 "如下爲支持Windows與Linux系統的瀏覽器 536 537 " 調用Firefox瀏覽器預覽,若是有安裝可取消註釋 538 " nmap <F5>ff :call ViewInBrowser("ff")<cr> 539 " imap <F5>ff <ESC>:call ViewInBrowser("ff")<cr> 540 541 " 調用Maxthon(遨遊)瀏覽器預覽,若是有安裝可取消註釋 542 " nmap <F5>ay :call ViewInBrowser("ay")<cr> 543 " imap <F5>ay <ESC>:call ViewInBrowser("ay")<cr> 544 545 " 調用Opera瀏覽器預覽,若是有安裝可取消註釋 546 " nmap <F5>op :call ViewInBrowser("op")<cr> 547 " imap <F5>op <ESC>:call ViewInBrowser("op")<cr> 548 549 " 調用Chrome瀏覽器預覽,若是有安裝可取消註釋 550 " nmap <F5>cr :call ViewInBrowser("cr")<cr> 551 " imap <F5>cr <ESC>:call ViewInBrowser("cr")<cr> 552 553 " 瀏覽器調用函數 554 function! ViewInBrowser(name) 555 if expand("%:e") == "php" || expand("%:e") == "html" 556 exe ":update" 557 if g:iswindows 558 "獲取要預覽的文件路徑,並將路徑中的'\'替換爲'/',同時將路徑文字的編碼轉換爲gbk(同cp936) 559 let file = iconv(substitute(expand("%:p"), '\', '/', "g"), "utf-8", "gbk") 560 561 "瀏覽器路徑設置,路徑中使用'/'斜槓,更改路徑請更改雙引號裏的內容 562 "下面只啓用了系統IE瀏覽器,如需啓用其它的可將其取消註釋(得先安裝,並配置好安裝路徑),也可按需增減 563 let SystemIE = "C:/progra~1/intern~1/iexplore.exe" "系統自帶IE目錄 564 " let IETester = "F:/IETester/IETester.exe" "IETester程序目錄(可按實際更改) 565 " let Chrome = "F:/Chrome/Chrome.exe" "Chrome程序目錄(可按實際更改) 566 " let Firefox = "F:/Firefox/Firefox.exe" "Firefox程序目錄(可按實際更改) 567 " let Opera = "F:/Opera/opera.exe" "Opera程序目錄(可按實際更改) 568 " let Maxthon = "C:/Progra~2/Maxthon/Bin/Maxthon.exe" "Maxthon程序目錄(可按實際更改) 569 570 "本地虛擬服務器設置,我測試的是phpStudy2014,可根據本身的修改,更改路徑請更改雙引號裏的內容 571 let htdocs ="F:/phpStudy2014/WWW/" "虛擬服務器地址或目錄(可按實際更改) 572 let url = "localhost" "虛擬服務器網址(可按實際更改) 573 elseif g:islinux 574 "暫時尚未配置,有時間再弄了。 575 endif 576 577 "瀏覽器調用縮寫,可根據實際增減,注意,上面瀏覽器路徑中沒有定義過的變量(等號右邊爲變量)不能出如今下面喲(可將其註釋或刪除) 578 let l:browsers = {} "定義縮寫字典變量,此行不能刪除或註釋 579 " let l:browsers["cr"] = Chrome "Chrome瀏覽器縮寫 580 " let l:browsers["ff"] = Firefox "Firefox瀏覽器縮寫 581 " let l:browsers["op"] = Opera "Opera瀏覽器縮寫 582 " let l:browsers["ay"] = Maxthon "遨遊瀏覽器縮寫 583 let l:browsers["ie"] = SystemIE "系統IE瀏覽器縮寫 584 " let l:browsers["ie6"] = IETester."-ie6" "調用IETESTER工具以IE6預覽縮寫(變量加參數) 585 " let l:browsers["ie7"] = IETester."-ie7" "調用IETESTER工具以IE7預覽縮寫(變量加參數) 586 " let l:browsers["ie8"] = IETester."-ie8" "調用IETESTER工具以IE8預覽縮寫(變量加參數) 587 " let l:browsers["ie9"] = IETester."-ie9" "調用IETESTER工具以IE9預覽縮寫(變量加參數) 588 " let l:browsers["ie10"] = IETester."-ie10" "調用IETESTER工具以IE10預覽縮寫(變量加參數) 589 " let l:browsers["iea"] = IETester."-al" "調用IETESTER工具以支持的全部IE版本預覽縮寫(變量加參數) 590 591 if stridx(file, htdocs) == -1 "文件不在本地虛擬服務器目錄,則直接預覽(但不能解析PHP文件) 592 exec ":silent !start ". l:browsers[a:name] ." file://" . file 593 else "文件在本地虛擬服務器目錄,則調用本地虛擬服務器解析預覽(先啓動本地虛擬服務器) 594 let file = substitute(file, htdocs, "http://".url."/", "g") "轉換文件路徑爲虛擬服務器網址路徑 595 exec ":silent !start ". l:browsers[a:name] file 596 endif 597 else 598 echohl WarningMsg | echo " please choose the correct source file" 599 endif 600 endfunction 601 602 " ----------------------------------------------------------------------------- 603 " < 其它配置 > 604 " ----------------------------------------------------------------------------- 605 set writebackup "保存文件前創建備份,保存成功後刪除該備份 606 set nobackup "設置無備份文件 607 " set noswapfile "設置無臨時文件 608 " set vb t_vb= "關閉提示音 609 610 611 " ============================================================================= 612 " << 如下爲經常使用插件配置 >> 613 " ============================================================================= 614 615 " ----------------------------------------------------------------------------- 616 " < a.vim 插件配置 > 617 " ----------------------------------------------------------------------------- 618 " 用於切換C/C++頭文件 619 " :A ---切換頭文件並獨佔整個窗口 620 " :AV ---切換頭文件並垂直分割窗口 621 " :AS ---切換頭文件並水平分割窗口 622 623 " ----------------------------------------------------------------------------- 624 " < Align 插件配置 > 625 " ----------------------------------------------------------------------------- 626 " 一個對齊的插件,用來——排版與對齊代碼,功能強大,不過用到的機會很少 627 628 " ----------------------------------------------------------------------------- 629 " < auto-pairs 插件配置 > 630 " ----------------------------------------------------------------------------- 631 " 用於括號與引號自動補全,不過會與函數原型提示插件echofunc衝突 632 " 因此我就沒有加入echofunc插件 633 634 " ----------------------------------------------------------------------------- 635 " < BufExplorer 插件配置 > 636 " ----------------------------------------------------------------------------- 637 " 快速輕鬆的在緩存中切換(至關於另外一種多個文件間的切換方式) 638 " <Leader>be 在當前窗口顯示緩存列表並打開選定文件 639 " <Leader>bs 水平分割窗口顯示緩存列表,並在緩存列表窗口中打開選定文件 640 " <Leader>bv 垂直分割窗口顯示緩存列表,並在緩存列表窗口中打開選定文件 641 642 " ----------------------------------------------------------------------------- 643 " < ccvext.vim 插件配置 > 644 " ----------------------------------------------------------------------------- 645 " 用於對指定文件自動生成tags與cscope文件並鏈接 646 " 若是是Windows系統, 則生成的文件在源文件所在盤符根目錄的.symbs目錄下(如: X:\.symbs\) 647 " 若是是Linux系統, 則生成的文件在~/.symbs/目錄下 648 " 具體用法可參考www.vim.org中此插件的說明 649 " <Leader>sy 自動生成tags與cscope文件並鏈接 650 " <Leader>sc 鏈接已存在的tags與cscope文件 651 652 " ----------------------------------------------------------------------------- 653 " < cSyntaxAfter 插件配置 > 654 " ----------------------------------------------------------------------------- 655 " 高亮括號與運算符等 656 au! BufRead,BufNewFile,BufEnter *.{c,cpp,h,java,javascript} call CSyntaxAfter() 657 658 " ----------------------------------------------------------------------------- 659 " < ctrlp.vim 插件配置 > 660 " ----------------------------------------------------------------------------- 661 " 一個全路徑模糊文件,緩衝區,最近最多使用,... 檢索插件;詳細幫助見 :h ctrlp 662 " 常規模式下輸入:Ctrl + p 調用插件 663 664 " ----------------------------------------------------------------------------- 665 " < emmet-vim(前身爲Zen coding) 插件配置 > 666 " ----------------------------------------------------------------------------- 667 " HTML/CSS代碼快速編寫神器,詳細幫助見 :h emmet.txt 668 669 " ----------------------------------------------------------------------------- 670 " < indentLine 插件配置 > 671 " ----------------------------------------------------------------------------- 672 " 用於顯示對齊線,與 indent_guides 在顯示方式上不一樣,根據本身喜愛選擇了 673 " 在終端上會有屏幕刷新的問題,這個問題能解決有更好了 674 " 開啓/關閉對齊線 675 nmap <leader>il :IndentLinesToggle<CR> 676 677 " 設置Gvim的對齊線樣式 678 if g:isGUI 679 let g:indentLine_char = "┊" 680 let g:indentLine_first_char = "┊" 681 endif 682 683 " 設置終端對齊線顏色,若是不喜歡能夠將其註釋掉採用默認顏色 684 let g:indentLine_color_term = 239 685 686 " 設置 GUI 對齊線顏色,若是不喜歡能夠將其註釋掉採用默認顏色 687 " let g:indentLine_color_gui = '#A4E57E' 688 689 " ----------------------------------------------------------------------------- 690 " < vim-javacompleteex(也就是 javacomplete 加強版)插件配置 > 691 " ----------------------------------------------------------------------------- 692 " java 補全插件 693 694 " ----------------------------------------------------------------------------- 695 " < Mark--Karkat(也就是 Mark) 插件配置 > 696 " ----------------------------------------------------------------------------- 697 " 給不一樣的單詞高亮,代表不一樣的變量時頗有用,詳細幫助見 :h mark.txt 698 699 " " ----------------------------------------------------------------------------- 700 " " < MiniBufExplorer 插件配置 > 701 " " ----------------------------------------------------------------------------- 702 " " 快速瀏覽和操做Buffer 703 " " 主要用於同時打開多個文件並相與切換 704 705 " " let g:miniBufExplMapWindowNavArrows = 1 "用Ctrl加方向鍵切換到上下左右的窗口中去 706 " let g:miniBufExplMapWindowNavVim = 1 "用<C-k,j,h,l>切換到上下左右的窗口中去 707 " let g:miniBufExplMapCTabSwitchBufs = 1 "功能加強(不過好像只有在Windows中才有用) 708 " " <C-Tab> 向前循環切換到每一個buffer上,並在但前窗口打開 709 " " <C-S-Tab> 向後循環切換到每一個buffer上,並在當前窗口打開 710 711 " 在不使用 MiniBufExplorer 插件時也可用<C-k,j,h,l>切換到上下左右的窗口中去 712 noremap <c-k> <c-w>k 713 noremap <c-j> <c-w>j 714 noremap <c-h> <c-w>h 715 noremap <c-l> <c-w>l 716 717 " ----------------------------------------------------------------------------- 718 " < neocomplcache 插件配置 > 719 " ----------------------------------------------------------------------------- 720 " 關鍵字補全、文件路徑補全、tag補全等等,各類,很是好用,速度超快。 721 let g:neocomplcache_enable_at_startup = 1 "vim 啓動時啓用插件 722 " let g:neocomplcache_disable_auto_complete = 1 "不自動彈出補全列表 723 " 在彈出補全列表後用 <c-p> 或 <c-n> 進行上下選擇效果比較好 724 725 " ----------------------------------------------------------------------------- 726 " < nerdcommenter 插件配置 > 727 " ----------------------------------------------------------------------------- 728 " 我主要用於C/C++代碼註釋(其它的也行) 729 " 如下爲插件默認快捷鍵,其中的說明是以C/C++爲例的,其它語言相似 730 " <Leader>ci 以每行一個 /* */ 註釋選中行(選中區域所在行),再輸入則取消註釋 731 " <Leader>cm 以一個 /* */ 註釋選中行(選中區域所在行),再輸入則稱重複註釋 732 " <Leader>cc 以每行一個 /* */ 註釋選中行或區域,再輸入則稱重複註釋 733 " <Leader>cu 取消選中區域(行)的註釋,選中區域(行)內至少有一個 /* */ 734 " <Leader>ca 在/*...*/與//這兩種註釋方式中切換(其它語言可能不同了) 735 " <Leader>cA 行尾註釋 736 let NERDSpaceDelims = 1 "在左註釋符以後,右註釋符以前留有空格 737 738 " ----------------------------------------------------------------------------- 739 " < nerdtree 插件配置 > 740 " ----------------------------------------------------------------------------- 741 " 有目錄村結構的文件瀏覽插件 742 743 " 常規模式下輸入 F2 調用插件 744 nmap <F2> :NERDTreeToggle<CR> 745 746 " ----------------------------------------------------------------------------- 747 " < omnicppcomplete 插件配置 > 748 " ----------------------------------------------------------------------------- 749 " 用於C/C++代碼補全,這種補全主要針對命名空間、類、結構、共同體等進行補全,詳細 750 " 說明能夠參考幫助或網絡教程等 751 " 使用前先執行以下 ctags 命令(本配置中能夠直接使用 ccvext 插件來執行如下命令) 752 " ctags -R --c++-kinds=+p --fields=+iaS --extra=+q 753 " 我使用上面的參數生成標籤後,對函數使用跳轉時會出現多個選擇 754 " 因此我就將--c++-kinds=+p參數給去掉了,若是大俠有什麼其它解決方法但願不要保留呀 755 set completeopt=menu "關閉預覽窗口 756 757 " ----------------------------------------------------------------------------- 758 " < powerline 插件配置 > 759 " ----------------------------------------------------------------------------- 760 " 狀態欄插件,更好的狀態欄效果 761 762 " ----------------------------------------------------------------------------- 763 " < repeat 插件配置 > 764 " ----------------------------------------------------------------------------- 765 " 主要用"."命令來重複上次插件使用的命令 766 767 " ----------------------------------------------------------------------------- 768 " < snipMate 插件配置 > 769 " ----------------------------------------------------------------------------- 770 " 用於各類代碼補全,這種補全是一種對代碼中的詞與代碼塊的縮寫補全,詳細用法能夠參 771 " 考使用說明或網絡教程等。不過有時候也會與 supertab 插件在補全時產生衝突,若是大 772 " 俠有什麼其它解決方法但願不要保留呀 773 774 " ----------------------------------------------------------------------------- 775 " < SrcExpl 插件配置 > 776 " ----------------------------------------------------------------------------- 777 " 加強源代碼瀏覽,其功能就像Windows中的"Source Insight" 778 nmap <F3> :SrcExplToggle<CR> "打開/閉瀏覽窗口 779 780 " ----------------------------------------------------------------------------- 781 " < std_c 插件配置 > 782 " ----------------------------------------------------------------------------- 783 " 用於加強C語法高亮 784 785 " 啓用 // 注視風格 786 let c_cpp_comments = 0 787 788 " ----------------------------------------------------------------------------- 789 " < surround 插件配置 > 790 " ----------------------------------------------------------------------------- 791 " 快速給單詞/句子兩邊增長符號(包括html標籤),缺點是不能用"."來重複命令 792 " 不過 repeat 插件能夠解決這個問題,詳細幫助見 :h surround.txt 793 794 " ----------------------------------------------------------------------------- 795 " < Syntastic 插件配置 > 796 " ----------------------------------------------------------------------------- 797 " 用於保存文件時查檢語法 798 799 " ----------------------------------------------------------------------------- 800 " < Tagbar 插件配置 > 801 " ----------------------------------------------------------------------------- 802 " 相對 TagList 能更好的支持面向對象 803 804 " 常規模式下輸入 tb 調用插件,若是有打開 TagList 窗口則先將其關閉 805 nmap tb :TlistClose<CR>:TagbarToggle<CR> 806 807 let g:tagbar_width=30 "設置窗口寬度 808 " let g:tagbar_left=1 "在左側窗口中顯示 809 810 " ----------------------------------------------------------------------------- 811 " < TagList 插件配置 > 812 " ----------------------------------------------------------------------------- 813 " 高效地瀏覽源碼, 其功能就像vc中的workpace 814 " 那裏面列出了當前文件中的全部宏,全局變量, 函數名等 815 816 " 常規模式下輸入 tl 調用插件,若是有打開 Tagbar 窗口則先將其關閉 817 nmap tl :TagbarClose<CR>:Tlist<CR> 818 819 let Tlist_Show_One_File=1 "只顯示當前文件的tags 820 " let Tlist_Enable_Fold_Column=0 "使taglist插件不顯示左邊的摺疊行 821 let Tlist_Exit_OnlyWindow=1 "若是Taglist窗口是最後一個窗口則退出Vim 822 let Tlist_File_Fold_Auto_Close=1 "自動摺疊 823 let Tlist_WinWidth=30 "設置窗口寬度 824 let Tlist_Use_Right_Window=1 "在右側窗口中顯示 825 826 " ----------------------------------------------------------------------------- 827 " < txtbrowser 插件配置 > 828 " ----------------------------------------------------------------------------- 829 " 用於文本文件生成標籤與與語法高亮(調用TagList插件生成標籤,若是能夠) 830 au BufRead,BufNewFile *.txt setlocal ft=txt 831 832 " ----------------------------------------------------------------------------- 833 " < ZoomWin 插件配置 > 834 " ----------------------------------------------------------------------------- 835 " 用於分割窗口的最大化與還原 836 " 常規模式下按快捷鍵 <c-w>o 在最大化與還原間切換 837 838 " ============================================================================= 839 " << 如下爲經常使用工具配置 >> 840 " ============================================================================= 841 842 " ----------------------------------------------------------------------------- 843 " < cscope 工具配置 > 844 " ----------------------------------------------------------------------------- 845 " 用Cscope本身的話說 - "你能夠把它當作是超過頻的ctags" 846 if has("cscope") 847 "設定可使用 quickfix 窗口來查看 cscope 結果 848 set cscopequickfix=s-,c-,d-,i-,t-,e- 849 "使支持用 Ctrl+] 和 Ctrl+t 快捷鍵在代碼間跳轉 850 set cscopetag 851 "若是你想反向搜索順序設置爲1 852 set csto=0 853 "在當前目錄中添加任何數據庫 854 if filereadable("cscope.out") 855 cs add cscope.out 856 "不然添加數據庫環境中所指出的 857 elseif $CSCOPE_DB != "" 858 cs add $CSCOPE_DB 859 endif 860 set cscopeverbose 861 "快捷鍵設置 862 nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR> 863 nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR> 864 nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR> 865 nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR> 866 nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR> 867 nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR> 868 nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR> 869 nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR> 870 endif 871 872 " ----------------------------------------------------------------------------- 873 " < ctags 工具配置 > 874 " ----------------------------------------------------------------------------- 875 " 對瀏覽代碼很是的方便,能夠在函數,變量之間跳轉等 876 set tags=./tags; "向上級目錄遞歸查找tags文件(好像只有在Windows下才有用) 877 878 " ----------------------------------------------------------------------------- 879 " < gvimfullscreen 工具配置 > 請確保已安裝了工具 880 " ----------------------------------------------------------------------------- 881 " 用於 Windows Gvim 全屏窗口,可用 F11 切換 882 " 全屏後再隱藏菜單欄、工具欄、滾動條效果更好 883 if (g:iswindows && g:isGUI) 884 nmap <F11> <Esc>:call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0)<CR> 885 endif 886 887 " ----------------------------------------------------------------------------- 888 " < vimtweak 工具配置 > 請確保以已裝了工具 889 " ----------------------------------------------------------------------------- 890 " 這裏只用於窗口透明與置頂 891 " 常規模式下 Ctrl + Up(上方向鍵) 增長不透明度,Ctrl + Down(下方向鍵) 減小不透明度,<Leader>t 窗口置頂與否切換 892 if (g:iswindows && g:isGUI) 893 let g:Current_Alpha = 255 894 let g:Top_Most = 0 895 func! Alpha_add() 896 let g:Current_Alpha = g:Current_Alpha + 10 897 if g:Current_Alpha > 255 898 let g:Current_Alpha = 255 899 endif 900 call libcallnr("vimtweak.dll","SetAlpha",g:Current_Alpha) 901 endfunc 902 func! Alpha_sub() 903 let g:Current_Alpha = g:Current_Alpha - 10 904 if g:Current_Alpha < 155 905 let g:Current_Alpha = 155 906 endif 907 call libcallnr("vimtweak.dll","SetAlpha",g:Current_Alpha) 908 endfunc 909 func! Top_window() 910 if g:Top_Most == 0 911 call libcallnr("vimtweak.dll","EnableTopMost",1) 912 let g:Top_Most = 1 913 else 914 call libcallnr("vimtweak.dll","EnableTopMost",0) 915 let g:Top_Most = 0 916 endif 917 endfunc 918 919 "快捷鍵設置 920 nmap <c-up> :call Alpha_add()<CR> 921 nmap <c-down> :call Alpha_sub()<CR> 922 nmap <leader>t :call Top_window()<CR> 923 endif 924 925 " ============================================================================= 926 " << 如下爲經常使用自動命令配置 >> 927 " ============================================================================= 928 929 " 自動切換目錄爲當前編輯文件所在目錄 930 au BufRead,BufNewFile,BufEnter * cd %:p:h 931 932 " ============================================================================= 933 " << windows 下解決 Quickfix 亂碼問題 >> 934 " ============================================================================= 935 " windows 默認編碼爲 cp936,而 Gvim(Vim) 內部編碼爲 utf-8,因此經常輸出爲亂碼 936 " 如下代碼能夠將編碼爲 cp936 的輸出信息轉換爲 utf-8 編碼,以解決輸出亂碼問題 937 " 但好像只對輸出信息所有爲中文才有滿意的效果,若是輸出信息是中英混合的,那可能 938 " 不成功,會形成其中一種語言亂碼,輸出信息所有爲英文的好像不會亂碼 939 " 若是輸出信息爲亂碼的能夠試一下下面的代碼,若是不行就仍是給它註釋掉 940 941 " if g:iswindows 942 " function QfMakeConv() 943 " let qflist = getqflist() 944 " for i in qflist 945 " let i.text = iconv(i.text, "cp936", "utf-8") 946 " endfor 947 " call setqflist(qflist) 948 " endfunction 949 " au QuickfixCmdPost make call QfMakeConv() 950 " endif 951 952 " ============================================================================= 953 " << 其它 >> 954 " ============================================================================= 955 " 注:上面配置中的"<Leader>"在本軟件中設置爲"\"鍵(引號裏的反斜槓),如<Leader>t 956 " 指在常規模式下按"\"鍵加"t"鍵,這裏不是同時按,而是先按"\"鍵後按"t"鍵,間隔在一 957 " 秒內,而<Leader>cs是先按"\"鍵再按"c"又再按"s"鍵;如要修改"<leader>"鍵,能夠把 958 " 下面的設置取消註釋,並修改雙引號中的鍵爲你想要的,如修改成逗號鍵。 959 960 "
3.在gvim中下載插件html
:BundleInstall
基本設置完成java
具體設置可見linux