侯体宗的博客
  • 首页
  • 人生(杂谈)
  • 技术
  • 关于我
  • 更多分类
    • 文件下载
    • 文字修仙
    • 中国象棋ai
    • 群聊
    • 九宫格抽奖
    • 拼图
    • 消消乐
    • 相册

PHP工程师VIM配置分享

php  /  管理员 发布于 7年前   164

关于我的vim配置

经常在服务器上写代码,一个朋友提供了关于他的vim配置,在此分享给大家。

界面效果图:

.vimrc

内容如下 

"=========================================================================set nocompatible       " be iMproved, requiredfiletype off         " required " git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim" set the runtime path to include Vundle and initializeset rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() " let Vundle manage Vundle, requiredPlugin 'gmarik/Vundle.vim' " plugin on GitHub repoPlugin '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.htmlPlugin '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 " 设定 << 和 >> 命令移动时的宽度为 4set 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 " 设定命令行的行数为 1set laststatus=2 " 显示状态栏 (默认值为 1, 无法显示状态栏)set statusline=\ %<%F[%1*%M%*%n%R%H]%=\ %y\ %0(%{&fileformat}\ %{&encoding}\ %c:%l/%L%)\ " 设置在状态行显示的信息set errorformat=%m\ in\ %f\ on\ line\ %lset autoindent set softtabstop=4 " 使得按退格键时可以一次删掉 4 个空格 colorscheme molokaiset t_Co=256  "-----------------------------------------------------------------" 获取当前系统类型"------------------------------------------------------------------function! MySys()  if has("win16") || has("win32") || has("win64") || has("win95")    return "windows"  elseif has("unix")    return "linux"  endifendfunction " 用户目录变量$VIMFILESif MySys() == "windows"  let $VIMFILES = $VIM.'/vimfiles'  set backupdir=D://Vim/tmpelseif MySys() == "linux"  let $VIMFILES = $HOME.'/.vim'  set backupdir=/tmpendif " 设置字体 以及中文支持if has("win32")  set guifont=Inconsolata:h12:cANSIendif " 配置多语言环境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  endifelse  echoerr "Sorry, this version of (g)vim was not compiled with +multi_byte"endif " 光标到上方窗口,需要k,非常麻烦,现在重映射为nnoremap  hnnoremap  jnnoremap  knnoremap  l "一些不错的映射转换语法(如果在一个文件中混合了不同语言时有用)nnoremap 1 :set filetype=xhtmlnnoremap 2 :set filetype=cssnnoremap 3 :set filetype=javascriptnnoremap 4 :set filetype=php "-----------------------------------------------------------------" 折叠配置"" manual 手工定义折叠" indent 更多的缩进表示更高级别的折叠" expr 用表达式来定义折叠" syntax 用语法高亮来定义折叠" diff 对没有更改的文本进行折叠" marker 对文中的标志折叠"------------------------------------------------------------------set foldenableset foldmethod=manualset 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.dictau 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 : Doxmap 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窗口是最后一个窗口,则退出vimlet Tlist_Use_Right_Window = 1 " 在右侧窗口中显示taglist窗口let Tlist_File_Fold_Auto_Close=1 " 自动折叠当前非编辑文件的方法列表let Tlist_Auto_Open = 0let Tlist_Auto_Update = 1let Tlist_Hightlight_Tag_On_BufEnter = 1let Tlist_Enable_Fold_Column = 0let 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的详细过程,希望对大家的学习有所帮助。

您可能感兴趣的文章:

  • Python开发如何在ubuntu 15.10 上配置vim
  • vim配置显示行号和语法高亮 即.vimrc文件的配置


  • 上一条:
    WordPress中用于检索模版的相关PHP函数使用解析
    下一条:
    WordPress中访客登陆实现邮件提醒的PHP脚本实例分享
  • 昵称:

    邮箱:

    0条评论 (评论内容有缓存机制,请悉知!)
    最新最热
    • 分类目录
    • 人生(杂谈)
    • 技术
    • linux
    • Java
    • php
    • 框架(架构)
    • 前端
    • ThinkPHP
    • 数据库
    • 微信(小程序)
    • Laravel
    • Redis
    • Docker
    • Go
    • swoole
    • Windows
    • Python
    • 苹果(mac/ios)
    • 相关文章
    • Laravel从Accel获得5700万美元A轮融资(0个评论)
    • PHP 8.4 Alpha 1现已发布!(0个评论)
    • 用Time Warden监控PHP中的代码处理时间(0个评论)
    • 在PHP中使用array_pop + yield实现读取超大型目录功能示例(0个评论)
    • Property Hooks RFC在PHP 8.4中越来越接近现实(0个评论)
    • 近期文章
    • 在windows10中升级go版本至1.24后LiteIDE的Ctrl+左击无法跳转问题解决方案(0个评论)
    • 智能合约Solidity学习CryptoZombie第四课:僵尸作战系统(0个评论)
    • 智能合约Solidity学习CryptoZombie第三课:组建僵尸军队(高级Solidity理论)(0个评论)
    • 智能合约Solidity学习CryptoZombie第二课:让你的僵尸猎食(0个评论)
    • 智能合约Solidity学习CryptoZombie第一课:生成一只你的僵尸(0个评论)
    • 在go中实现一个常用的先进先出的缓存淘汰算法示例代码(0个评论)
    • 在go+gin中使用"github.com/skip2/go-qrcode"实现url转二维码功能(0个评论)
    • 在go语言中使用api.geonames.org接口实现根据国际邮政编码获取地址信息功能(1个评论)
    • 在go语言中使用github.com/signintech/gopdf实现生成pdf分页文件功能(95个评论)
    • gmail发邮件报错:534 5.7.9 Application-specific password required...解决方案(0个评论)
    • 近期评论
    • 122 在

      学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..
    • 123 在

      Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..
    • 原梓番博客 在

      在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..
    • 博主 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..
    • 1111 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
    • 2016-10
    • 2016-11
    • 2017-06
    • 2017-07
    • 2017-08
    • 2017-09
    • 2017-11
    • 2017-12
    • 2018-01
    • 2018-02
    • 2018-03
    • 2020-03
    • 2020-04
    • 2020-05
    • 2020-06
    • 2020-07
    • 2020-09
    • 2021-02
    • 2021-03
    • 2021-04
    • 2021-05
    • 2021-06
    • 2021-07
    • 2021-08
    • 2021-09
    • 2021-10
    • 2021-11
    • 2021-12
    • 2022-01
    • 2022-02
    • 2022-05
    • 2022-06
    • 2022-07
    • 2022-08
    • 2022-09
    • 2022-10
    • 2022-11
    • 2022-12
    • 2023-01
    • 2023-02
    • 2023-03
    • 2023-04
    • 2023-05
    • 2023-06
    • 2023-07
    • 2023-08
    • 2023-09
    • 2023-10
    • 2023-11
    • 2023-12
    • 2024-01
    • 2024-02
    • 2024-03
    • 2024-04
    • 2024-05
    • 2024-06
    • 2024-07
    • 2024-09
    Top

    Copyright·© 2019 侯体宗版权所有· 粤ICP备20027696号 PHP交流群

    侯体宗的博客