PHP工程师VIM配置分享_PHP
程序员文章站
2024-01-06 10:19:52
...
关于我的vim配置
经常在服务器上写代码,一个朋友提供了关于他的vim配置,在此分享给大家。
界面效果图:
.vimrc
内容如下
"========================================================================= 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 " 自动语法高亮 set number " 显示行号 set cursorline " 突出显示当前行 " set ruler " 打开状态栏标尺 set shiftwidth=4 " 设定 > 命令移动时的宽度为 4 set tabstop=4 expandtab " 设定 tab 长度为 4 个空格 set nobackup " 覆盖文件时不备份 " set autochdir " 自动切换当前目录为当前文件所在的目录 set backupcopy=yes " 设置备份时的行为为覆盖 set ignorecase smartcase " 搜索时忽略大小写,但在有一个或以上大写字母时仍保持对大小写敏感 set nowrapscan " 禁止在搜索到文件两端时重新搜索 " set incsearch " 输入搜索内容时就显示搜索结果 set hlsearch " 搜索时高亮显示被找到的文本 set noerrorbells " 关闭错误信息响铃 set novisualbell " 关闭使用可视响铃代替呼叫 set t_vb= " 置空错误铃声的终端代码 set magic " 设置魔术 set hidden " 允许在有未保存的修改时切换缓冲区,此时的修改由 vim 负责保存 set guioptions-=T " 隐藏工具栏 set guioptions-=m " 隐藏菜单栏 set smartindent " 开启新行时使用智能自动缩进 set backspace=indent,eol,start " 不设定在插入状态无法用退格键和 Delete 键删除回车符 set cmdheight=1 " 设定命令行的行数为 1 set laststatus=2 " 显示状态栏 (默认值为 1, 无法显示状态栏) set statusline=\ %k,非常麻烦,现在重映射为 nnoremap h nnoremap j nnoremap k nnoremap l "一些不错的映射转换语法(如果在一个文件中混合了不同语言时有用) nnoremap 1 :set filetype=xhtml nnoremap 2 :set filetype=css nnoremap 3 :set filetype=javascript nnoremap 4 :set filetype=php "----------------------------------------------------------------- " 折叠配置 " " manual 手工定义折叠 " indent 更多的缩进表示更高级别的折叠 " expr 用表达式来定义折叠 " syntax 用语法高亮来定义折叠 " diff 对没有更改的文本进行折叠 " marker 对文中的标志折叠 "------------------------------------------------------------------ set foldenable set foldmethod=manual set foldlevel=100 " 启动vim时不要自动折叠代码 set foldcolumn=0 " 设置折叠栏宽度 " Python 文件的一般设置,比如不要 tab 等 " autocmd FileType python set tabstop=4 shiftwidth=4 expandtab " autocmd FileType python map :!python % " 设置数据字典 ~/.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 :if IsWinManagerVisible() WMToggle else WMToggle :q endif " " nmap :WMToggle " " 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 " let g:DoxygenToolkit_briefTag_funcName="no" let g:doxygen_enhanced_color=1 map fg : Dox map ffg : DoxAuthor "----------------------------------------------------------------- " plugin - NERDTree 配置 "----------------------------------------------------------------- let NERDTreeWinPos="left" let NERDTreeWinSize=30 " let NERDTreeChDirMode=1 " 改变tree目录的同时改变工程的目录 nnoremap :NERDTreeToggle "----------------------------------------------------------------- " 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 :!ctags -R --exclude=*.js --c++-kinds=+p --fields=+iaS --extra=+q . "----------------------------------------------------------------- " plugin - taglist.vim "----------------------------------------------------------------- let Tlist_Show_One_File = 1 " 不同时显示多个文件的tag,只显示当前文件的 let Tlist_Exit_OnlyWindow = 1 " 如果taglist窗口是最后一个窗口,则退出vim let Tlist_Use_Right_Window = 1 " 在右侧窗口中显示taglist窗口 let Tlist_File_Fold_Auto_Close=1 " 自动折叠当前非编辑文件的方法列表 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 :TlistToggle "----------------------------------------------------------------- " plugin - cscope设置 "----------------------------------------------------------------- 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 s :cs find s =expand(" ") nmap g :cs find g =expand(" ") nmap c :cs find c =expand(" ") nmap t :cs find t =expand(" ") nmap e :cs find e =expand(" ") nmap f :cs find f =expand(" ") nmap i :cs find i =expand(" ") nmap d :cs find d =expand(" ") endif "----------------------------------------------------------------- " plugin - project.vim 组织项目列表 " \C 递归读取子目录 \c 读取当前文件 " \l (列出所有当前层文件)\L(递归),按任何键停止 " \w (关闭当前层文件)\W(递归) " \g (在项目当前层文件搜索)\G(递归) " \r 关闭子文件夹并刷新当前文件夹下文件,\R递归打开文件夹并刷新所有文件 " \s 关闭文件夹并创建,\S递归打开文件夹并创建 " \s 将文件在水平打开多个窗口显示,打开或关闭文件夹列表 " \o 将文件在一个窗口打开,打开或关闭文件夹列表 " \v 在右窗口显示指针停留在project窗口的文件内容 " \i 显示文件或文件夹的设置参数,如filter="*" " \I 显示文件或文件夹的决对路径和参数 " \1 - \9,\f1-\f9,\F1-\F9执行指定命令,\0查询1-9命令,\f0查询f1-f9,F1-F9命令 " 空格扩大project窗口的宽度,恢复宽度 "----------------------------------------------------------------- " let proj_window_width=24 " let proj_window_increment=12 " let loaded_project = 1 " 停用插架 " let proj_flags="imstcg" " 自动隐藏project列表 " nnoremap :Project " F5 打开project窗口 "----------------------------------------------------------------- " plugin - NERD_commenter.vim 注释代码用的, " [count],cc 光标以下count行逐行添加注释(7,cc) " [count],cu 光标以下count行逐行取消注释(7,cu) " [count],cm 光标以下count行尝试添加块注释(7,cm) " ,cA 在行尾插入 /* */,并且进入插入模式。 这个命令方便写注释。 " 注:count参数可选,无则默认为选中行或当前行 "----------------------------------------------------------------- let NERDSpaceDelims=1 " 让注释符与语句之间留一个空格 let NERDCompactSexyComs=1 " 多行注释时样子更好看 "----------------------------------------------------------------- " plugin - ctrlp 设置 "----------------------------------------------------------------- nnoremap :ClearAllCtrlPCache \|:CtrlP
使用步骤:
1、下载插件管理器
~/.vim/bundle/Vundle.vim
2、安装插件
打开一个文件
vim ~/.vimrc
进入命令执行安装
:BundleInstall
3、上传PHP自动实例字典及本色方案,解压至 .vim 目录下
以上就是配置VIM的详细过程,希望对大家的学习有所帮助。