壹佰网|ERP100 - 企业信息化知识门户

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 565|回复: 0

我的vim配置文件

[复制链接]
发表于 2012/7/29 14:15:09 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。如果您注册时有任何问题请联系客服QQ: 83569622  。

您需要 登录 才可以下载或查看,没有帐号?注册

x
本帖最后由 lujun9972 于 2012/7/29 14:17 编辑
  1. "===================================================================
  2. "其他设置
  3. set path+=./../inc/
  4. set backupdir=/tmp
  5. " Chinese
  6. "set encoding=utf-8
  7. "set langmenu=zh_CN.UTF-8
  8. "language message zh_CN.UTF-8
  9. set fileencodings=ucs-bom,utf-8,unicode,gb18030,cp936,big5,euc-jp,euc-kr,latin1

  10. " 设置在状态行显示的信息
  11. "set statusline=\ %<%F[%1*%M%*%n%R%H]%=\ %y\ %0(%{&fileformat}\ [%{(&fenc==""?&enc:&fenc).(&bomb?",BOM":"")}]\ %c:%l/%L%)\


  12. "设定PHP开发环境
  13. " php语法进行检测 ctrl+p启动
  14. map <C-P> :!/usr/bin/php -l %<CR>
  15. " php启动帮助 快捷键普通模式下K
  16. autocmd BufNewFile,Bufread *.ros,*.inc,*.php set keywordprg="help

  17. "设定VimOrganization插件
  18. au BufEnter *.org            call org#SetOrgFileType()
  19. let g:org_todo_setup='TODO | DONE | DOING | CANCELED'
  20. "let g:org_tags_alist='{@home(h) @work(w) @tennisclub(t)} {easy(e) hard(d)} {computer(c) phone(p)}'
  21. "高亮光标所在行
  22. set cursorline






  23. "===================================================================
  24. " 设置文件的后缀与类型的关系
  25. autocmd BufReadPost *.src set filetype=ace
  26. autocmd BufReadPost *.sqc set filetype=c
  27. autocmd BufReadPost *.ec set filetype=c
  28. "When .vimrc is edited, reload it
  29. autocmd! bufwritepost _vimrc source $HOME/.vimrc







  30. "====================================================================
  31. "定义键缩写!!

  32. "set mapleader
  33. let mapleader=","
  34. "  定义下面的键映射,利用它可以在当前文件中快速查找光标下的单词,并打开窗口位置列表显示出来:
  35. nmap <leader>lv :lv /<c-r>=expand("<cword>")<cr>/ %<cr>:lw<cr>
  36. "  定义tag跳转命令
  37. "  定义pt,在预览窗口查看定义
  38. nmap pt <C-w>}<C-w>k
  39. nmap gt <C-]>
  40. "使用NERDTree插件查看工程文件。设置快捷键,速记法:file list
  41. nmap <Leader>fl :NERDTreeToggle<CR>
  42. nmap <leader>fe :Sexplore!<cr>
  43. "使用TagList插件查看工程文件。设置快捷键,速记法:tag list
  44. nmap <leader>tl :TlistToggle<cr>
  45. nmap <leader>wm :WMToggle<cr>
  46. nmap <leader>wa :WMToggle<cr>:NERDTreeToggle<CR>
  47. "搭建IDE的快捷键
  48. nmap <leader>save :call SaveProject()<CR>
  49. nmap <leader>wipe :call WipeProject()<CR>
  50. "设定自动生成tags
  51. "nmap <C-F12> :!ctags -a -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
  52. nmap <C-F12> :!ctags -a -R --fields=+iaS --extra=+q --exclude="project.vim" .<CR>
  53. "nmap <C-F12> :call RebuildTags()<CR>
  54. function! RebuildTags()
  55.     if filereadable("./tags")
  56.         delete("./tags")
  57.     endif
  58.     system("ctags -R --extra=+q --fields=+iaS .")
  59. endfunction
  60. "Fast reloading of the .vimrc
  61. nmap <leader>s :source $HOME/.vimrc<cr>
  62. "Fast editing of .vimrc
  63. nmap <silent> <leader>e :e $HOME/.vimrc<cr>
  64. "设置F3打开日历
  65. nmap <F3> :CalendarH<CR>
  66. "设置<C-c>为关闭窗口
  67. "nmap <C-c> :q<CR>
  68. nmap <C-c> :call MyQuit()<CR>
  69. "<C-F3>为取出<C-M>
  70. nmap <C-F3> :%s/<C-q><C-M>//g<CR>
  71. "设置,pj为打开关闭Project窗口
  72. nmap <silent> <Leader>pj <Plug>ToggleProject
  73. "设置F1
  74. inoremap <F1> <C-x><C-o>
  75. "设置窗口切换
  76. nnoremap <C-h> <C-w>h
  77. nnoremap <C-j> <C-w>j
  78. nnoremap <C-k> <C-w>k
  79. nnoremap <C-l> <C-w>l

  80. "====================================================================
  81. "插件配置
  82. "配置pathogen
  83. call pathogen#infect()
  84. "LookupFile setting
  85. let g:LookupFile_DisableDefaultMap = 1
  86. nmap <unique> <silent> <F4> <Plug>LookupFile
  87. " netrw setting
  88. let g:netrw_winsize = 30

  89. "设置TagList
  90. "标签列表窗口显示或隐藏不影响整个gvim窗口大小
  91. let Tlist_Inc_Winwidth=0
  92. let Tlist_Show_One_File=1
  93. let Tlist_Exit_OnlyWindow=1
  94. "let Tlist_Use_SingleClick=1
  95. "不显示Menu
  96. let Tlist_Show_Menu=0
  97. "let Tlist_Use_Right_Window=1
  98. "let Tlist_Auto_Open=1
  99. "let Tlist_WinWidth=20

  100. "设置windowsmanager
  101. "let loaded_winmanager = 1
  102. let g:winManagerWindowLayout='BufExplorer|TagList'
  103. let g:winmanagerPos="right"
  104. "设置NERDTree子窗口宽度
  105. let NERDTreeWinSize=23
  106. "设置NERDTree子窗口位置
  107. let NERDTreeWinPos="left"

  108. "设置grep
  109. "nnoremap <silent> <F3> :Grep<CR>

  110. "设置自动补全
  111. filetype plugin indent on
  112. set completeopt=longest,menu,preview

  113. "设置代码折叠类型
  114. set foldmethod=syntax
  115. "启动vim时不要自动折叠代码
  116. set foldlevel=100

  117. "设置颜色方案
  118. if v:progname =~? "gvim"
  119.     colorscheme evening
  120. endif

  121. "设置OmniCpp
  122. let OmniCpp_GlobalScopeSearch=1
  123. let OmniCpp_NamespaceSearch=2

  124. "设定calendar插件
  125. let g:calendar_datetime='statusline'




  126. "====================================================================
  127. "我的脚本
  128. "  设置mksession
  129. "    设置sessionoptions可以用在UNIX下
  130. set sessionoptions+=slash
  131. set sessionoptions+=unix
  132. "    设置sessionoptions使用相对路径
  133. set sessionoptions-=curdir      
  134. set sessionoptions+=sesdir      
  135. set sessionoptions-=blank
  136. "设置启动时自动退出时自动保存读取项目相关配置

  137. function! SaveProject()
  138.     "不保存winManger窗口
  139.     WMClose
  140.     "不保存NERDTree窗口
  141.     NERDTreeClose
  142.     "不保存Tlist,如果有__Tag_List__,说明打开了Tlist,保存之前那么关闭Tlist
  143.     if(bufexists("__Tag_List__")!=0)
  144.         TlistClose
  145.     endif
  146.     echo "Saving ".s:curProjectSession
  147.     execute 'mksession! '.s:curProjectSession
  148.     echo "Saving ".s:curProjectInfo
  149.     execute 'wviminfo! '.s:curProjectInfo
  150. endfunction
  151. function! AutoSaveProject()
  152.     if(argc()==0 && (filereadable(s:curProjectSession) || filereadable(s:curProjectInfo)))
  153.         call SaveProject()
  154.     endif
  155. endfunction

  156. function! LoadProject()
  157.     let s:curWorkDir=getcwd()
  158.     let s:curProjectSession=s:curWorkDir."/project.vim"
  159.     let s:curProjectInfo=s:curWorkDir."/project.viminfo"
  160.     if(filereadable(s:curProjectSession))
  161.         "echo "Loading ".s:curProjectSession
  162.         execute 'source '.s:curProjectSession
  163.     endif
  164.     if(filereadable(s:curProjectInfo))
  165.         "echo "Loading ".s:curProjectInfo
  166.         execute 'rviminfo '.s:curProjectInfo
  167.     endif
  168. endfunction
  169. function! AutoLoadProject()
  170.     if(argc()==0)
  171.         call LoadProject()
  172.     endif
  173. endfunction


  174. function! WipeProject()
  175.     if(delete(s:curProjectSession)==0)
  176.         echo "Deleted ".s:curProjectSession
  177.         " delete(s:curProjectSession)
  178.     endif
  179.     if(delete(s:curProjectInfo)==0)
  180.         "echo "Deleted ".s:curProjectInfo
  181.     endif
  182. endfunction

  183. autocmd VimEnter * call AutoLoadProject()
  184. autocmd VimLeave * call AutoSaveProject()

  185. "设定find的path变量
  186. function! MyFind()
  187.     let oldPath=&path
  188.     set path+=**
  189.     let fileName=input("请输入要查找的文件名:")
  190.     execute "find ".fileName
  191.     let &path=oldPath
  192. endfunction
  193. nmap <F6> :call MyFind()<CR>


  194. "C-c 退出脚本
  195. function! MyQuit()
  196.     if winbufnr(2)==-1
  197.         if tabpagenr('
  198. )==1
  199.             "只有一个tab页,则提示是否退出
  200.             echo "请用:q退出"
  201.         else
  202.             close
  203.         endif
  204.     else
  205.         quit
  206.     endif
  207. endfunction
  208. "读取文件类型配置
  209. let s:myVimrcPath="~/.vim/myVimrc/"
  210. function LoadMyVimrc()
  211.         let s:myVimrcPathFt=s:myVimrcPath.expand("%:e")."/"
  212.         let s:myVimrcFilesFt=s:myVimrcPathFt."*.vim"
  213.         echo glob(s:myVimrcFilesFt)
  214.         let s:myVimrcFilesFtList=split(glob(s:myVimrcFilesFt))
  215.         for s:myVimrcFileFt in s:myVimrcFilesFtList
  216.                 if executable(s:myVimrcFileFt)
  217.                         source s:myVimrcFileFt
  218.                 endif
  219.         endfor
  220. endfunction

复制代码

QQ|Archiver|小黑屋|手机版|壹佰网 ERP100 ( 京ICP备19053597号-2 )

Copyright © 2005-2012 北京海之大网络技术有限责任公司 服务器托管由互联互通
手机:13911575376
网站技术点击发送消息给对方83569622   广告&合作 点击发送消息给对方27675401   点击发送消息给对方634043306   咨询及人才点击发送消息给对方138011526

GMT+8, 2025/11/30 01:18 , Processed in 0.013776 second(s), 16 queries , File On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表