PHP工程師VIM配置分享
關(guān)于我的vim配置
經(jīng)常在服務(wù)器上寫代碼,一個(gè)朋友提供了關(guān)于他的vim配置,在此分享給大家。
界面效果圖:
.vimrc
內(nèi)容如下
"========================================================================= set nocompatible " be iMproved, required filetype off " required " git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim " set the runtime path to include Vundle and initialize set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() " let Vundle manage Vundle, required Plugin 'gmarik/Vundle.vim' " plugin on GitHub repo Plugin 'shawncplus/phpcomplete.vim' Plugin 'scrooloose/nerdtree' Plugin 'kien/ctrlp.vim' Plugin 'bling/vim-airline' Plugin 'scrooloose/syntastic' Plugin 'vim-scripts/DoxygenToolkit.vim' Plugin 'scrooloose/nerdcommenter' Plugin 'MarcWeber/vim-addon-mw-utils' Plugin 'tomtom/tlib_vim' Plugin 'garbas/vim-snipmate' " Optional: Plugin 'honza/vim-snippets' " plugin from http://vim-scripts.org/vim/scripts.html Plugin 'vim-scripts/bufexplorer.zip' Plugin 'vim-scripts/cscope.vim' Plugin 'vim-scripts/taglist.vim' " Plugin 'vim-scripts/winmanager' " Plugin 'vim-scripts/project.tar.gz' call vundle#end() " 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 filetype plugin on " required syntax on " 自動(dòng)語法高亮 set number " 顯示行號(hào) set cursorline " 突出顯示當(dāng)前行 " set ruler " 打開狀態(tài)欄標(biāo)尺 set shiftwidth=4 " 設(shè)定 << 和 >> 命令移動(dòng)時(shí)的寬度為 4 set tabstop=4 expandtab " 設(shè)定 tab 長度為 4 個(gè)空格 set nobackup " 覆蓋文件時(shí)不備份 " set autochdir " 自動(dòng)切換當(dāng)前目錄為當(dāng)前文件所在的目錄 set backupcopy=yes " 設(shè)置備份時(shí)的行為為覆蓋 set ignorecase smartcase " 搜索時(shí)忽略大小寫,但在有一個(gè)或以上大寫字母時(shí)仍保持對(duì)大小寫敏感 set nowrapscan " 禁止在搜索到文件兩端時(shí)重新搜索 " set incsearch " 輸入搜索內(nèi)容時(shí)就顯示搜索結(jié)果 set hlsearch " 搜索時(shí)高亮顯示被找到的文本 set noerrorbells " 關(guān)閉錯(cuò)誤信息響鈴 set novisualbell " 關(guān)閉使用可視響鈴代替呼叫 set t_vb= " 置空錯(cuò)誤鈴聲的終端代碼 set magic " 設(shè)置魔術(shù) set hidden " 允許在有未保存的修改時(shí)切換緩沖區(qū),此時(shí)的修改由 vim 負(fù)責(zé)保存 set guioptions-=T " 隱藏工具欄 set guioptions-=m " 隱藏菜單欄 set smartindent " 開啟新行時(shí)使用智能自動(dòng)縮進(jìn) set backspace=indent,eol,start " 不設(shè)定在插入狀態(tài)無法用退格鍵和 Delete 鍵刪除回車符 set cmdheight=1 " 設(shè)定命令行的行數(shù)為 1 set laststatus=2 " 顯示狀態(tài)欄 (默認(rèn)值為 1, 無法顯示狀態(tài)欄) set statusline=\ %<%F[%1*%M%*%n%R%H]%=\ %y\ %0(%{&fileformat}\ %{&encoding}\ %c:%l/%L%)\ " 設(shè)置在狀態(tài)行顯示的信息 set errorformat=%m\ in\ %f\ on\ line\ %l set autoindent set softtabstop=4 " 使得按退格鍵時(shí)可以一次刪掉 4 個(gè)空格 colorscheme molokai set t_Co=256 "----------------------------------------------------------------- " 獲取當(dāng)前系統(tǒng)類型 "------------------------------------------------------------------ function! MySys() if has("win16") || has("win32") || has("win64") || has("win95") return "windows" elseif has("unix") return "linux" endif endfunction " 用戶目錄變量$VIMFILES if MySys() == "windows" let $VIMFILES = $VIM.'/vimfiles' set backupdir=D://Vim/tmp elseif MySys() == "linux" let $VIMFILES = $HOME.'/.vim' set backupdir=/tmp endif " 設(shè)置字體 以及中文支持 if has("win32") set guifont=Inconsolata:h12:cANSI endif " 配置多語言環(huán)境 if has("multi_byte") " UTF-8 編碼 set encoding=utf-8 set termencoding=utf-8 set formatoptions+=mM set fencs=utf-8,gbk if v:lang =~? '^\(zh\)\|\(ja\)\|\(ko\)' set ambiwidth=double endif if has("win32") source $VIMRUNTIME/delmenu.vim source $VIMRUNTIME/menu.vim language messages zh_CN.utf-8 endif else echoerr "Sorry, this version of (g)vim was not compiled with +multi_byte" endif " 光標(biāo)到上方窗口,需要<c-w><c-w>k,非常麻煩,現(xiàn)在重映射為<c-k> nnoremap <C-h> <C-w>h nnoremap <C-j> <C-w>j nnoremap <C-k> <C-w>k nnoremap <C-l> <C-w>l "一些不錯(cuò)的映射轉(zhuǎn)換語法(如果在一個(gè)文件中混合了不同語言時(shí)有用) nnoremap <leader>1 :set filetype=xhtml<CR> nnoremap <leader>2 :set filetype=css<CR> nnoremap <leader>3 :set filetype=javascript<CR> nnoremap <leader>4 :set filetype=php<CR> "----------------------------------------------------------------- " 折疊配置 " " manual 手工定義折疊 " indent 更多的縮進(jìn)表示更高級(jí)別的折疊 " expr 用表達(dá)式來定義折疊 " syntax 用語法高亮來定義折疊 " diff 對(duì)沒有更改的文本進(jìn)行折疊 " marker 對(duì)文中的標(biāo)志折疊 "------------------------------------------------------------------ set foldenable set foldmethod=manual set foldlevel=100 " 啟動(dòng)vim時(shí)不要自動(dòng)折疊代碼 set foldcolumn=0 " 設(shè)置折疊欄寬度 " Python 文件的一般設(shè)置,比如不要 tab 等 " autocmd FileType python set tabstop=4 shiftwidth=4 expandtab " autocmd FileType python map <F12> :!python %<CR> " 設(shè)置數(shù)據(jù)字典 ~/.vim/dict/文件的路徑 set complete-=k complete+=k " autocmd filetype javascript set dictionary=$VIMFILES/dict/javascript.dict " autocmd filetype css set dictionary=$VIMFILES/dict/css.dict au FileType php setlocal dict+=$VIMFILES/dict/php.dict "----------------------------------------------------------------- " plugin - winManager 配置 (棄用,很多小bug) "----------------------------------------------------------------- " let g:winManagerWindowLayout="NERDTree,TagList" " let g:winManagerWidth = 35 " let g:NERDTree_title="[NERDTree]" " " nmap <silent> <C-m> :if IsWinManagerVisible() <BAR> WMToggle<CR> <BAR> else <BAR> WMToggle<CR>:q<CR> endif <CR> " " nmap <C-m> :WMToggle<CR> " " function! NERDTree_Start() " exec 'NERDTree' " endfunction " " function! NERDTree_IsValid() " return 1 " endfunction "----------------------------------------------------------------- " plugin - doxygen toolkit 配置 "----------------------------------------------------------------- let g:DoxygenToolkit_briefTag_pre="@brief " let g:DoxygenToolkit_paramTag_pre="@Param " let g:DoxygenToolkit_returnTag="@return " let g:DoxygenToolkit_authorName="jiangyh <jiangyahui@#>" let g:DoxygenToolkit_briefTag_funcName="no" let g:doxygen_enhanced_color=1 map fg : Dox<cr> map ffg : DoxAuthor<cr> "----------------------------------------------------------------- " plugin - NERDTree 配置 "----------------------------------------------------------------- let NERDTreeWinPos="left" let NERDTreeWinSize=30 " let NERDTreeChDirMode=1 " 改變tree目錄的同時(shí)改變工程的目錄 nnoremap <silent><F6> :NERDTreeToggle<CR> "----------------------------------------------------------------- " plugin - ctags程序 "----------------------------------------------------------------- if MySys() == "windows" let Tlist_Ctags_Cmd = '"'.$VIMRUNTIME.'/ctags.exe"' elseif MySys() == "linux" let Tlist_Ctags_Cmd = '/usr/bin/ctags' endif set tags=~/acl/tags; nnoremap <silent><F8> :!ctags -R --exclude=*.js --c++-kinds=+p --fields=+iaS --extra=+q .<CR> "----------------------------------------------------------------- " plugin - taglist.vim "----------------------------------------------------------------- let Tlist_Show_One_File = 1 " 不同時(shí)顯示多個(gè)文件的tag,只顯示當(dāng)前文件的 let Tlist_Exit_OnlyWindow = 1 " 如果taglist窗口是最后一個(gè)窗口,則退出vim let Tlist_Use_Right_Window = 1 " 在右側(cè)窗口中顯示taglist窗口 let Tlist_File_Fold_Auto_Close=1 " 自動(dòng)折疊當(dāng)前非編輯文件的方法列表 let Tlist_Auto_Open = 0 let Tlist_Auto_Update = 1 let Tlist_Hightlight_Tag_On_BufEnter = 1 let Tlist_Enable_Fold_Column = 0 let Tlist_Compact_Format = 1 " let Tlist_Display_Prototype = 0 nnoremap <silent><F7> :TlistToggle<CR> "----------------------------------------------------------------- " plugin - cscope設(shè)置 "----------------------------------------------------------------- set cscopequickfix=s-,c-,d-,i-,t-,e- if has("cscope") set csprg=/usr/bin/cscope set csto=1 set cst set nocsverb " add any database in current directory " if filereadable("cscope.out") " cs add cscope.out " endif " set csverb " endif nmap <C-@>s :cs find s <C-R>=expand("<cword>")<CR><CR> nmap <C-@>g :cs find g <C-R>=expand("<cword>")<CR><CR> nmap <C-@>c :cs find c <C-R>=expand("<cword>")<CR><CR> nmap <C-@>t :cs find t <C-R>=expand("<cword>")<CR><CR> nmap <C-@>e :cs find e <C-R>=expand("<cword>")<CR><CR> nmap <C-@>f :cs find f <C-R>=expand("<cfile>")<CR><CR> nmap <C-@>i :cs find i <C-R>=expand("<cfile>")<CR><CR> nmap <C-@>d :cs find d <C-R>=expand("<cword>")<CR><CR> endif "----------------------------------------------------------------- " plugin - project.vim 組織項(xiàng)目列表 " \C 遞歸讀取子目錄 \c 讀取當(dāng)前文件 " \l (列出所有當(dāng)前層文件)\L(遞歸),按任何鍵停止 " \w (關(guān)閉當(dāng)前層文件)\W(遞歸) " \g (在項(xiàng)目當(dāng)前層文件搜索)\G(遞歸) " \r 關(guān)閉子文件夾并刷新當(dāng)前文件夾下文件,\R遞歸打開文件夾并刷新所有文件 " \s 關(guān)閉文件夾并創(chuàng)建,\S遞歸打開文件夾并創(chuàng)建 " \s 將文件在水平打開多個(gè)窗口顯示,打開或關(guān)閉文件夾列表 " \o 將文件在一個(gè)窗口打開,打開或關(guān)閉文件夾列表 " \v 在右窗口顯示指針停留在project窗口的文件內(nèi)容 " \i 顯示文件或文件夾的設(shè)置參數(shù),如filter="*" " \I 顯示文件或文件夾的決對(duì)路徑和參數(shù) " \1 - \9,\f1-\f9,\F1-\F9執(zhí)行指定命令,\0查詢1-9命令,\f0查詢f1-f9,F(xiàn)1-F9命令 " <space>空格擴(kuò)大project窗口的寬度,恢復(fù)寬度 "----------------------------------------------------------------- " let proj_window_width=24 " let proj_window_increment=12 " let loaded_project = 1 " 停用插架 " let proj_flags="imstcg" " 自動(dòng)隱藏project列表 " nnoremap <silent><F5> :Project<CR> " F5 打開project窗口 "----------------------------------------------------------------- " plugin - NERD_commenter.vim 注釋代碼用的, " [count],cc 光標(biāo)以下count行逐行添加注釋(7,cc) " [count],cu 光標(biāo)以下count行逐行取消注釋(7,cu) " [count],cm 光標(biāo)以下count行嘗試添加塊注釋(7,cm) " ,cA 在行尾插入 /* */,并且進(jìn)入插入模式。 這個(gè)命令方便寫注釋。 " 注:count參數(shù)可選,無則默認(rèn)為選中行或當(dāng)前行 "----------------------------------------------------------------- let NERDSpaceDelims=1 " 讓注釋符與語句之間留一個(gè)空格 let NERDCompactSexyComs=1 " 多行注釋時(shí)樣子更好看 "----------------------------------------------------------------- " plugin - ctrlp 設(shè)置 "----------------------------------------------------------------- nnoremap <silent> <C-p> :ClearAllCtrlPCache<CR>\|:CtrlP<CR>
使用步驟:
1、下載插件管理器
~/.vim/bundle/Vundle.vim
2、安裝插件
打開一個(gè)文件
vim ~/.vimrc
進(jìn)入命令執(zhí)行安裝
:BundleInstall
3、上傳PHP自動(dòng)實(shí)例字典及本色方案,解壓至 .vim 目錄下
以上就是配置VIM的詳細(xì)過程,希望對(duì)大家的學(xué)習(xí)有所幫助。
相關(guān)文章
PHP調(diào)用Linux命令權(quán)限不足問題解決方法
這篇文章主要介紹了PHP調(diào)用Linux命令權(quán)限不足問題解決方法,本文是解決項(xiàng)目問題總結(jié)而來,通過修改sudo配置文件解決無權(quán)限執(zhí)行命令問題,需要的朋友可以參考下2015-02-02array_values()在php中返回?cái)?shù)組的操作實(shí)例
在本篇文章里小編給大家分享的是一篇關(guān)于array_values()在php中返回?cái)?shù)組的操作實(shí)例內(nèi)容,有興趣的朋友們可以學(xué)習(xí)參考下。2021-02-02PHP基于PDO調(diào)用sqlserver存儲(chǔ)過程通用方法【基于Yii框架】
這篇文章主要介紹了PHP基于PDO調(diào)用sqlserver存儲(chǔ)過程通用方法,結(jié)合實(shí)例形式分析了基于Yii框架采用pdo調(diào)用sqlserver存儲(chǔ)過程的相關(guān)操作步驟與實(shí)現(xiàn)技巧,需要的朋友可以參考下2017-10-10