Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7111279
  • 博文数量: 3857
  • 博客积分: 6409
  • 博客等级: 准将
  • 技术积分: 15948
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-02 16:48
个人简介

迷彩 潜伏 隐蔽 伪装

文章分类

全部博文(3857)

文章存档

2017年(5)

2016年(63)

2015年(927)

2014年(677)

2013年(807)

2012年(1241)

2011年(67)

2010年(7)

2009年(36)

2008年(28)

分类:

2012-12-05 19:23:28

原文地址:我的vimrc 配置 作者:seujww


点击(此处)折叠或打开

  1. """"""""""""""""""""""""""""""""""""""""""""
  2. " basic setting
  3. """""""""""""""""""""""""""""""""""""""""""
  4. set number
  5. set ruler
  6. set backspace=indent,eol,start
  7. set showmatch

  8. set hlsearch
  9. set incsearch


  10. """ 去掉vi一致性
  11. set nocompatible

  12. """ 设置ambiwidth
  13. " set ambiwidth=double

  14. " set confirm
  15. set showcmd

  16. " set laststatus=2
  17. " set history=700
  18. " set cursorline
  19. " set autochdir
  20. " set ignorecase


  21. """ Tab键的宽度
  22. set tabstop=4
  23. """ 统一缩进为4
  24. set softtabstop=4
  25. set shiftwidth=4
  26. """ 用空格代替制表符
  27. " set expandtab


  28. """ 自动缩进
  29. set autoindent
  30. " set smartindent
  31. " set cindent


  32. """ 语法高亮
  33. syntax enable
  34. syntax on


  35. """ 颜色模式
  36. " colorscheme anotherdark


  37. """ 填充匹配的右括号
  38. " inoremap ( ()
  39. " inoremap { {}<LEFT>
  40. " inoremap [ []


  41. """ 设置编码
  42. set encoding=utf-8
  43. set termencoding=gb2312
  44. set fileencodings=ucs-bom,utf-8,gb18030,utf-16,big5,chinese


  45. """ 鼠标设置
  46. " set mouse=a
  47. " set mousemodel=popup
  48. " set selection=exclusive
  49. " set selectmode=mouse,key
  50. " behave mswin


  51. """ 代码折叠
  52. " set foldenable
  53. " foldmethod : indent, manual, syntax, expr, diff, marker
  54. " set foldmethod=indent
  55. " set foldopen=all
  56. " set foldclose=all
  57. " set foldcolumn=4
  58. " setlocal foldlevel=100
  59. """ fold cmd : zf zo zc zd zr zm zR zM zn zi zN
  60. " nnoremap <silent> <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>


  61. """ 侦测文件类型
  62. filetype on
  63. """ 载入文件类型插件
  64. filetype plugin indent on

  65. """ 关掉智能补全时的预览窗口
  66. " set completeopt=longest,menu

  67. """ 设置的leader
  68. let mapleader=","


  69. """""""""""""""""""""""""""""
  70. " basic快捷操作
  71. """""""""""""""""""""""""""""
  72. nmap <silent> ( 5<c-w><
  73. nmap <silent> ) 5<c-w>>
  74. nmap <silent> - 5<c-w>-
  75. nmap <silent> = 5<c-w>+
  76. map <tab> <c-w><c-w>
  77. nnoremap <F3> :Grep<space>


  78. """""""""""""""""""""""""
  79. " basic代码补全
  80. """""""""""""""""""""""""
  81. """ CTRL-N和CTRL-P能对局部变量进行补全
  82. """ CTRL-P一般的含义是向上;CTRL-N是向下查找以进行补全
  83. " inoremap <C-]> <C-X><C-]> "根据标签补全
  84. " inoremap <C-F> <C-X><C-F> "补全文件名
  85. " inoremap <C-D> <C-X><C-D> "补全宏定义
  86. " inoremap <C-L> <C-X><C-L> "整行补全


  87. """"""""""""""""""""""""""""""
  88. " netrw setting
  89. """"""""""""""""""""""""""""""
  90. " nmap fe :***plore!
  91. " let g:netrw_winsize = 30


  92. """"""""""""""""""""""""""""""
  93. " MiniBufExplorer
  94. """"""""""""""""""""""""""""""
  95. " nmap <silent> mb :MiniBufExplorer<cr>
  96. " let g:miniBufExplMapWindowNavVim = 1 "按下Ctrl+h/j/k/l,可以切换到当前窗口的上下左右窗口
  97. " let g:miniBufExplMapWindowNavArrows = 1 "按下Ctrl+箭头,可以切换到当前窗口的上下左右窗口
  98. " let g:miniBufExplMapCTabSwitchBufs =1
  99. " let g:miniBufExplModSelTarget =1


  100. """"""""""""""""""""""""""""""
  101. " BufExplorer
  102. """"""""""""""""""""""""""""""
  103. " nmap <silent> bf :BufExplorer<cr>
  104. let g:bufExplorerDefaultHelp=0 " Do not show default help.
  105. let g:bufExplorerShowRelativePath=1 " Show relative paths.
  106. let g:bufExplorerSortBy='mru' " Sort by most recently used.
  107. let g:bufExplorerSplitRight=0 " Split left.
  108. let g:bufExplorerSplitVertical=1 " Split vertically.
  109. let g:bufExplorerSplitVertSize = 30 " Split width
  110. " let g:bufExplorerUseCurrentWindow=1 " Open in new window.
  111. " autocmd BufWinEnter \[Buf\ List\] setl nonumber



  112. """""""""""""""""""""""""
  113. " winManager
  114. """""""""""""""""""""""""
  115. nmap <silent> wm :WMToggle<cr>
  116. nmap <silent> <leader>fir :FirstExplorerWindow<cr>
  117. nmap <silent> <leader>bot :BottomExplorerWindow<cr>

  118. """ option : BufExplorer, FileExplorer, TagList
  119. let g:winManagerWindowLayout = "BufExplorer|FileExplorer"
  120. " let g:persistentBehaviour=0 " 如果所有编辑文件都关闭了,退出vim
  121. let g:winManagerWidth = 30
  122. let g:defaultExplorer = 1
  123. let g:persistentBehaviour=0 "只剩一个窗口时, 退出vim.



  124. """"""""""""""""""""""""""""
  125. " NERDTree NERD_commenter
  126. """"""""""""""""""""""""""""
  127. map nd :NERDTree
  128. map nc :NERDTreeClose

  129. """ 对NERD_commenter的设置
  130. " [count],cc 光标以下count行逐行添加注释(7,cc)
  131. " [count],cu 光标以下count行逐行取消注释(7,cu)
  132. " [count],cm 光标以下count行尝试添加块注释(7,cm)
  133. " ,ca,在可选的注释方式之间切换,如块注释/* */和行注释//
  134. " ,cA 在行尾插入 ,并且进入插入模式。 这个命令方便写注释。
  135. """ 注:count参数可选,无则默认为选中行或当前行

  136. let NERDShutUp=1 "在光标所在行上,按下一次ctrl+h是注释,再按下一次是取消注释
  137. let NERDSpaceDelims=1 " 让注释符与语句之间留一个空格
  138. let NERDCompact***yComs=1 " 多行注释时样子更好看



  139. """""""""""""""""""""""""
  140. " ctags
  141. """""""""""""""""""""""""
  142. """ Ctrl+] 压栈(跳到标记定义处); Ctrl+W ] 在横着的新窗口打开(:stag tagname)
  143. """ n Ctrl+t 出栈(后跳n次,会使你的:tags列出的表缩短); 跨文件时,用 Ctrl+o才能跳回去

  144. """ 定制的tags
  145. " set tags+=/home/xxxxx/.vimhome/vim72/share/vim/vimfiles/tags/cpp_tags
  146. set tags+=/home/xxxxx/.vimhome/vim72/share/vim/vimfiles/tags/glib_tags
  147. set tags+=/home/xxxxx/.vimhome/vim72/share/vim/vimfiles/tags/libc_tags
  148. set tags+=/home/xxxxx/.vimhome/vim72/share/vim/vimfiles/tags/susv2_tags

  149. """ cmd : ctags -R --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ cpp_src
  150. """ generate ctags for current folder
  151. """ add current directory's generated tags file to available tags
  152. """ map <F12> <ESC>:!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR><CR>
  153. " map :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q . :TlistUpdate
  154. " set tags+=./tags

  155. noremap <space><F12> <ESC>:call Do_ctags()<CR><CR>

  156. function Do_ctags()
  157.      execute "!ctags -R --c++-kinds=+p --fields=+ialS --extra=+q '.'"
  158.      execute "set tags+=./tags"
  159.      execute "TlistUpdate"
  160. endf



  161. """""""""""""""""""""""""
  162. " taglist
  163. """""""""""""""""""""""""
  164. map tl :TlistToggle

  165. let Tlist_Ctags_Cmd='/home/xxxxx/.vimhome/ctags58/bin/ctags'
  166. let Tlist_Show_One_File=1
  167. let Tlist_Exit_OnlyWindow=1
  168. let Tlist_Use_Right_Window=1 " 把taglist窗口放在屏幕的右侧,缺省在左侧
  169. let Tlist_Process_File_Always=1 "实时更新tags
  170. " let Tlist_Show_Menu=1 " 显示taglist菜单
  171. " let Tlist_File_Fold_Auto_Close=1 " 让当前不被编辑的文件的方法列表自动折叠起来

  172. if(v:version >= 700)
  173.     set completeopt=longest,menu
  174. endif



  175. """""""""""""""""""""""""""""""""
  176. " OmniCppComplete
  177. """""""""""""""""""""""""""""""""
  178. inoremap <expr> <CR> pumvisible()?"\":"\"
  179. inoremap <expr> <C-J> pumvisible()?"\\\":"\"
  180. inoremap <expr> <C-K> pumvisible()?"\\\":"\"
  181. inoremap <expr> <C-U> pumvisible()?"\":"\"

  182. let OmniCpp_NamespaceSearch = 1
  183. let OmniCpp_GlobalScopeSearch = 1
  184. let OmniCpp_ShowAccess = 1

  185. let OmniCpp_MayCompleteDot = 1 " autocomplete with .
  186. let OmniCpp_MayCompleteArrow = 1 " autocomplete with ->
  187. let OmniCpp_MayCompleteScope = 1 " autocomplete with ::
  188. let OmniCpp_SelectFirstItem = 2 " select first item (but don't insert)
  189. let OmniCpp_NamespaceSearch = 2 " search namespaces in this and included files
  190. let OmniCpp_ShowPrototypeInAbbr = 1 " show function prototype (i.e. parameters) in popup window

  191. " auto close options when exiting insert mode
  192. " autocmd InsertLeave * if pumvisible() == 0|pclose|endif
  193. " set completeopt=menu,menuone



  194. """""""""""""""""""""""""""""""""
  195. " cscope
  196. """""""""""""""""""""""""""""""""
  197. """ cscope -Rbqk "项目根目录运行,为代码生成一个cscope数据库
  198. """ R 表示把所有子目录里的文件也建立索引; b 表示cscope不启动自带的用户界面,而仅仅建立符号数据库
  199. """ q 生成cscope.in.out和cscope.po.out文件,加快cscope的索引速度; k 在生成索引文件时,不搜索/usr/include目录
  200. """ Tab键来进行匹配内容和输入项的切换; ctrl+r,ctrl+d退出 cscope

  201. " cscope -Rbq -f path/xxx.out
  202. " cs add path/xxx.out
  203. " noremap <space><F9> <ESC>:!find . -name "*.h" -o -name "*.c" -o -name "*.cc" > ./cscope.files <CR><CR>
  204. " noremap :!cscope -Rbkq -i cscope.files
  205. " noremap <space><F11> <ESC>:!cs add cscope.out <CR><CR>

  206. if has("cscope")
  207.     set csprg=/home/xxxxx/.vimhome/cscope157/bin/cscope
  208.     set csto=0
  209.     set cscopetag
  210.     set nocsverb
  211.     "add any database in current directory
  212.     if filereadable("cscope.out")
  213.         cs add cscope.out
  214.     " else add database pointed to by environment     
  215.     elseif $CSCOPE_DB != ""
  216.         cs add $CSCOPE_DB
  217.     endif
  218.     set csverb
  219.     set cscopetag
  220.     "使用 quickfix 窗口来显示 cscope 结果
  221.     set cscopequickfix=s-,g-,c-,d-,t-,e-,f-,i-
  222. endif

  223. " nmap <C-\>s :cs find s <C-R>=expand("")<CR><CR> "s:查找C语言符号,即查找函数名,宏,枚举值等出现的地方
  224. " nmap <C-\>g :cs find g <C-R>=expand("")<CR><CR> "g:查找函数,宏,枚举等定义的位置,类似ctags所提供的功能
  225. " nmap <C-\>c :cs find c <C-R>=expand("")<CR><CR> "c:查找调用本函数的函数
  226. " nmap <C-\>t :cs find t <C-R>=expand("")<CR><CR> "t:查找指定的字符串
  227. " nmap <C-\>e :cs find e <C-R>=expand("")<CR><CR> "e:查找egrep模式,相当于egrep功能,但查找速度快多了
  228. " nmap <C-\>f :cs find f <C-R>=expand("")<CR><CR> "f:查找并打开文件,类似vim的find功能
  229. " nmap <C-\>i :cs find i ^<C-R>=expand("")<CR>$<CR> "i: 查找包含本文件
  230. " nmap <C-\>d :cs find d <C-R>=expand("")<CR><CR> "d:查找本函数调用的函数
  231. nmap :cs find s =expand("<cword>") :cw

  232. noremap :call Do_CsTag()

  233. function Do_CsTag()
  234.     if(executable('cscope') && has("cscope") )
  235.         silent! execute "!find . -name '*.h' -o -name '*.c' -o -name '*.cpp' -o -name '*.php' > cscope.files"
  236.         silent! execute "!cscope -Rbkq"
  237.         if filereadable("cscope.out")
  238.             execute "cs add cscope.out"
  239.         endif
  240.     endif
  241. endf



  242. """""""""""""""""""""""""""""""""
  243. " 在 h 和 .c/.cpp 文件中切换
  244. """""""""""""""""""""""""""""""""
  245. nnoremap <silent> <F8> <ESC>:A<CR>
  246. nnoremap <silent> <F10> <ESC>:AS<CR>
  247. nnoremap <silent> <F11> <ESC>:AV<CR>


  248. """""""""""""""""""""""""
  249. " superTab
  250. """""""""""""""""""""""""
  251. let g:SuperTabRetainCompletionType=2
  252. let g:SuperTabDefaultCompletionType="<C-X><C-O>"


  253. """""""""""""""""""""""""
  254. " snipMate
  255. """""""""""""""""""""""""
  256. """ 将snipMate的快捷键转到ctrl+j, 因为默认的快捷键tab会和pydiction冲突
  257. " ino <c-j> <c-r>=TriggerSnippet()<cr>
  258. " snor i=TriggerSnippet()



  259. """""""""""""""""""""""""
  260. " QuickFix
  261. """""""""""""""""""""""""
  262. """ cn 切换到下一个结果; cp 切换到上一个结果
  263. """ cc 显示详细错误信息; cl 列出所有错误
  264. """ cw 如果有错误列表,则打开quickfix窗口
  265. """ col cnew 到前一个旧(后一个较新)的错误列表
  266. """ (先按,再按空格)就可以编译,使用”cp“和”cn“跳到上一个和下一个错误"cw"来打开一个quickfix窗口

  267. " autocmd FileType c,cpp map <buffer> <leader><space> :w<cr>:make<cr>
  268. " nmap cn :cn
  269. " nmap <leader>cp :cp<cr>
  270. " nmap cw :cw 10
  271. nmap q :q


  272. """""""""""""""""""""""""
  273. " echofunc
  274. """""""""""""""""""""""""
  275. """ 按键"Alt+-"和"Alt+="向前和向后翻页
  276. let g:EchoFuncKeyNext=''
  277. let g:EchoFuncKeyPrev=''

  278. if(v:version >= 700)
  279.     set laststatus=2
  280.     if has('statusline')
  281.         let g:EchoFuncShowOnStatus=1
  282.         set statusline=%<%f\ %{EchoFuncGetStatusLine()}\ %h%m%r%=%-10.(%l,%c%V%)\ %P(%L)\
  283.     endif
  284. endif



  285. """""""""""""""""""""""""""""""""
  286. " php 全能提示触发命令
  287. """""""""""""""""""""""""""""""""
  288. " if !exists('g:AutoComplPop_Behavior')
  289. "    let g:AutoComplPop_Behavior = {}
  290. "    let g:AutoComplPop_Behavior['php'] = []
  291. "    call add(g:AutoComplPop_Behavior['php'], {
  292. "                \ 'command' : "\<C-x>\<C-o>",
  293. "                \ 'pattern' : printf('\(->\|::\|\$\)\k\{%d,}$', 0),
  294. "                \ 'repeat' : 0,
  295. "                \})
  296. " endif



  297. """""""""""""""""""""""""""""""""
  298. " assistant 支持PHP、JS、Vim脚本
  299. """""""""""""""""""""""""""""""""
  300. """ 显示当前位置函数或者变量名等关键字的原型
  301. """ <C-x><C-u> 补全当前位置关键字



  302. """""""""""""""""""""""""""""""""""
  303. " c cpp IDE
  304. """""""""""""""""""""""""""""""""""
  305. if(v:version >= 700)
  306.     set runtimepath+=/home/xxxxx/.vimhome/vim72/share/vim/cvim_IDE
  307.     set runtimepath+=/home/xxxxx/.vimhome/vim72/share/vim/cvim_IDE/after
  308. endif



  309. """""""""""""""""""""""""""""""""""
  310. " bash IDE
  311. """""""""""""""""""""""""""""""""""
  312. " if(v:version >= 700)
  313. "    set runtimepath+=/home/xxxxx/.vimhome/vim72/share/vim/bash_IDE
  314. "    set runtimepath+=/home/xxxxx/.vimhome/vim72/share/vim/bash_IDE/after
  315. " endif



  316. """""""""""""""""""""""""""""""""
  317. " python IDE
  318. """""""""""""""""""""""""""""""""
  319. """ Python代码检查(pyflakes)
  320. """ 执行命令:cc,即可进行代码检查

  321. """ VimPdb 调试Python程序
  322. """ F5运行,F2设置断点,在运行到断点后可以用按F12可以查看
  323. """ F7/F8 - Step into/over,F12 - Print stack trace
  324. """ F3/Ctrl-F3 - Eval/Exec a given statement (in the current debugging context)

  325. if(v:version >= 700)
  326.     let $PYTHONHOME="/home/xxxxx/.vimhome/python273"
  327. "    set runtimepath+=/home/xxxxx/.vimhome/vim72/share/vim/python_IDE
  328. "    set runtimepath+=/home/xxxxx/.vimhome/vim72/share/vim/python_IDE/after

  329. "    autocmd FileType python set omnifunc=pythoncomplete#Complete

  330.     let g:pydiction_location = '/home/xxxxx/.vimhome/vim72/share/vim/python_IDE/pydiction/complete-dict'
  331.     let g:pydiction_menu_height = 20
  332. endif

  333. autocmd FileType python set expandtab



  334. """""""""""""""""""""""""""""""""
  335. " 记录文件上次编辑的位置
  336. """""""""""""""""""""""""""""""""
  337. if(v:version >= 700)
  338.     autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe " g'\"" | endif
  339. endif

  340. " autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe " g'\"" | endif


=============================================================================================

""""""""""""""""""""""""""""""""""""""""""""
" basic setting
"""""""""""""""""""""""""""""""""""""""""""
set number
set ruler
set backspace=indent,eol,start
set showmatch

set hlsearch
set incsearch


""" 去掉vi一致性
set nocompatible

""" 设置ambiwidth
" set ambiwidth=double

" set confirm 
set showcmd

" set laststatus=2 
" set history=700
" set cursorline
" set autochdir
" set ignorecase


""" Tab键的宽度
set tabstop=4
""" 统一缩进为4
set softtabstop=4
set shiftwidth=4
""" 用空格代替制表符 
" set expandtab


""" 自动缩进
set autoindent
" set smartindent
" set cindent


""" 语法高亮
syntax enable
syntax on


""" 颜色模式
" colorscheme anotherdark 


""" 填充匹配的右括号
" inoremap ( ()
" inoremap { {}
" inoremap [ []


""" 设置编码
set encoding=utf-8
set termencoding=gb2312
set fileencodings=ucs-bom,utf-8,gb18030,utf-16,big5,chinese


""" 鼠标设置
" set mouse=a 
" set mousemodel=popup 
" set selection=exclusive
" set selectmode=mouse,key 
" behave mswin


""" 代码折叠  
" set foldenable
" foldmethod : indent, manual, syntax, expr, diff, marker  
" set foldmethod=indent
" set foldopen=all 
" set foldclose=all 
" set foldcolumn=4
" setlocal foldlevel=100
""" fold cmd : zf zo zc zd zr zm zR zM zn zi zN 
" nnoremap @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')


""" 侦测文件类型 
filetype on
""" 载入文件类型插件
filetype plugin indent on

""" 关掉智能补全时的预览窗口
" set completeopt=longest,menu

""" 设置的leader 
let mapleader=","


"""""""""""""""""""""""""""""
" basic快捷操作
"""""""""""""""""""""""""""""
nmap ( 5<
nmap ) 5>
nmap - 5-
nmap = 5+
map
nnoremap :Grep


"""""""""""""""""""""""""
" basic代码补全
"""""""""""""""""""""""""
""" CTRL-N和CTRL-P能对局部变量进行补全
""" CTRL-P一般的含义是向上;CTRL-N是向下查找以进行补全
" inoremap "根据标签补全
" inoremap "补全文件名
" inoremap "补全宏定义
" inoremap "整行补全


""""""""""""""""""""""""""""""
" netrw setting
""""""""""""""""""""""""""""""
" nmap fe :***plore! 
" let g:netrw_winsize = 30


""""""""""""""""""""""""""""""
" MiniBufExplorer 
""""""""""""""""""""""""""""""
" nmap mb :MiniBufExplorer 
" let g:miniBufExplMapWindowNavVim = 1  "按下Ctrl+h/j/k/l,可以切换到当前窗口的上下左右窗口
" let g:miniBufExplMapWindowNavArrows = 1 "按下Ctrl+箭头,可以切换到当前窗口的上下左右窗口
" let g:miniBufExplMapCTabSwitchBufs =1
" let g:miniBufExplModSelTarget =1


""""""""""""""""""""""""""""""
"  BufExplorer
""""""""""""""""""""""""""""""
" nmap bf :BufExplorer
let g:bufExplorerDefaultHelp=0       " Do not show default help.
let g:bufExplorerShowRelativePath=1  " Show relative paths.
let g:bufExplorerSortBy='mru'        " Sort by most recently used.
let g:bufExplorerSplitRight=0        " Split left.
let g:bufExplorerSplitVertical=1     " Split vertically.
let g:bufExplorerSplitVertSize = 30  " Split width
" let g:bufExplorerUseCurrentWindow=1  " Open in new window.
" autocmd BufWinEnter \[Buf\ List\] setl nonumber 



"""""""""""""""""""""""""
" winManager 
"""""""""""""""""""""""""
nmap wm :WMToggle
nmap fir :FirstExplorerWindow
nmap bot :BottomExplorerWindow

""" option : BufExplorer, FileExplorer, TagList
let g:winManagerWindowLayout = "BufExplorer|FileExplorer"
" let g:persistentBehaviour=0 " 如果所有编辑文件都关闭了,退出vim
let g:winManagerWidth = 30
let g:defaultExplorer = 1
let g:persistentBehaviour=0   "只剩一个窗口时, 退出vim.



""""""""""""""""""""""""""""
" NERDTree  NERD_commenter
""""""""""""""""""""""""""""
map nd :NERDTree
map nc :NERDTreeClose

""" 对NERD_commenter的设置 
" [count],cc 光标以下count行逐行添加注释(7,cc)
" [count],cu 光标以下count行逐行取消注释(7,cu)
" [count],cm 光标以下count行尝试添加块注释(7,cm)
" ,ca,在可选的注释方式之间切换,如块注释/* */和行注释//
" ,cA 在行尾插入 ,并且进入插入模式。 这个命令方便写注释。
""" 注:count参数可选,无则默认为选中行或当前行

let NERDShutUp=1  "在光标所在行上,按下一次ctrl+h是注释,再按下一次是取消注释
let NERDSpaceDelims=1 " 让注释符与语句之间留一个空格
let NERDCompact***yComs=1 " 多行注释时样子更好看



"""""""""""""""""""""""""
" ctags 
"""""""""""""""""""""""""
""" Ctrl+] 压栈(跳到标记定义处); Ctrl+W ] 在横着的新窗口打开(:stag tagname)
""" n Ctrl+t 出栈(后跳n次,会使你的:tags列出的表缩短); 跨文件时,用 Ctrl+o才能跳回去

""" 定制的tags 
" set tags+=/home/xxxxx/.vimhome/vim72/share/vim/vimfiles/tags/cpp_tags
set tags+=/home/xxxxx/.vimhome/vim72/share/vim/vimfiles/tags/glib_tags
set tags+=/home/xxxxx/.vimhome/vim72/share/vim/vimfiles/tags/libc_tags
set tags+=/home/xxxxx/.vimhome/vim72/share/vim/vimfiles/tags/susv2_tags

""" cmd : ctags -R --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ cpp_src
""" generate ctags for current folder 
""" add current directory's generated tags file to available tags
""" map :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q . 
" map :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q . :TlistUpdate
" set tags+=./tags

noremap :call Do_ctags()

function Do_ctags()
silent! execute "!ctags -R --c++-kinds=+p --fields=+ialS --extra=+q '.'"
silent! execute "set tags+=./tags"
silent! execute "TlistUpdate"
endf



"""""""""""""""""""""""""
" taglist
"""""""""""""""""""""""""
map  tl :TlistToggle

let Tlist_Ctags_Cmd='/home/xxxxx/.vimhome/ctags58/bin/ctags'
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1
let Tlist_Use_Right_Window=1 " 把taglist窗口放在屏幕的右侧,缺省在左侧
let Tlist_Process_File_Always=1 "实时更新tags
" let Tlist_Show_Menu=1 " 显示taglist菜单
" let Tlist_File_Fold_Auto_Close=1 " 让当前不被编辑的文件的方法列表自动折叠起来

if(v:version >= 700)
set completeopt=longest,menu
endif



"""""""""""""""""""""""""""""""""
" OmniCppComplete
"""""""""""""""""""""""""""""""""
inoremap pumvisible()?"\":"\"
inoremap pumvisible()?"\\\":"\"
inoremap pumvisible()?"\\\":"\"
inoremap pumvisible()?"\":"\

let OmniCpp_NamespaceSearch = 1
let OmniCpp_GlobalScopeSearch = 1
let OmniCpp_ShowAccess = 1

let OmniCpp_MayCompleteDot = 1 " autocomplete with .
let OmniCpp_MayCompleteArrow = 1 " autocomplete with ->
let OmniCpp_MayCompleteScope = 1 " autocomplete with ::
let OmniCpp_SelectFirstItem = 2 " select first item (but don't insert)
let OmniCpp_NamespaceSearch = 2 " search namespaces in this and included files
let OmniCpp_ShowPrototypeInAbbr = 1 " show function prototype (i.e. parameters) in popup window

" auto close options when exiting insert mode
" autocmd InsertLeave * if pumvisible() == 0|pclose|endif
" set completeopt=menu,menuone



"""""""""""""""""""""""""""""""""
" cscope
"""""""""""""""""""""""""""""""""
""" cscope -Rbqk  "项目根目录运行,为代码生成一个cscope数据库
""" R 表示把所有子目录里的文件也建立索引; b 表示cscope不启动自带的用户界面,而仅仅建立符号数据库
""" q 生成cscope.in.out和cscope.po.out文件,加快cscope的索引速度; k 在生成索引文件时,不搜索/usr/include目录 
""" Tab键来进行匹配内容和输入项的切换; ctrl+r,ctrl+d退出 cscope

" cscope -Rbq -f path/xxx.out
" cs add path/xxx.out
" noremap :!find . -name "*.h" -o -name "*.c" -o -name "*.cc" > ./cscope.files
" noremap :!cscope -Rbkq -i cscope.files
" noremap :!cs add cscope.out

if has("cscope")
set csprg=/home/xxxxx/.vimhome/cscope157/bin/cscope
set csto=0
set cscopetag 
set nocsverb
"add any database in current directory
if filereadable("cscope.out")
cs add cscope.out
" else add database pointed to by environment
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
set csverb
    set cscopetag
"使用 quickfix 窗口来显示 cscope 结果
    set cscopequickfix=s-,g-,c-,d-,t-,e-,f-,i- 
endif

" nmap s :cs find s =expand("") "s:查找C语言符号,即查找函数名,宏,枚举值等出现的地方
" nmap g :cs find g =expand("") "g:查找函数,宏,枚举等定义的位置,类似ctags所提供的功能
" nmap c :cs find c =expand("") "c:查找调用本函数的函数
" nmap t :cs find t =expand("") "t:查找指定的字符串
" nmap e :cs find e =expand("") "e:查找egrep模式,相当于egrep功能,但查找速度快多了
" nmap f :cs find f =expand("") "f:查找并打开文件,类似vim的find功能
" nmap i :cs find i ^=expand("")$ "i: 查找包含本文件
" nmap d :cs find d =expand("") "d:查找本函数调用的函数
nmap   :cs find s =expand("") :cw  

noremap :call Do_CsTag()

function Do_CsTag()
if(executable('cscope') && has("cscope") )
silent! execute "!find . -name '*.h' -o -name '*.c' -o -name '*.cpp' -o -name '*.php' > cscope.files"
silent! execute "!cscope -Rbkq"
if filereadable("cscope.out")
execute "cs add cscope.out"
endif
endif
endf



"""""""""""""""""""""""""""""""""
" 在 h 和 .c/.cpp 文件中切换
"""""""""""""""""""""""""""""""""
nnoremap :A
nnoremap :AS
nnoremap :AV


"""""""""""""""""""""""""
" superTab 
"""""""""""""""""""""""""
let g:SuperTabRetainCompletionType=2
let g:SuperTabDefaultCompletionType=""


"""""""""""""""""""""""""
" snipMate
"""""""""""""""""""""""""
""" 将snipMate的快捷键转到ctrl+j, 因为默认的快捷键tab会和pydiction冲突
" ino =TriggerSnippet()
" snor i=TriggerSnippet()



"""""""""""""""""""""""""
" QuickFix
"""""""""""""""""""""""""
""" cn 切换到下一个结果; cp 切换到上一个结果
""" cc 显示详细错误信息; cl 列出所有错误  
""" cw 如果有错误列表,则打开quickfix窗口
""" col cnew 到前一个旧(后一个较新)的错误列表
""" (先按,再按空格)就可以编译,使用”cp“和”cn“跳到上一个和下一个错误"cw"来打开一个quickfix窗口   

" autocmd FileType c,cpp  map :w:make
" nmap cn :cn
" nmap cp :cp
" nmap cw :cw 10
nmap q :q


"""""""""""""""""""""""""
" echofunc 
"""""""""""""""""""""""""
""" 按键"Alt+-"和"Alt+="向前和向后翻页
let g:EchoFuncKeyNext='
let g:EchoFuncKeyPrev=''

if(v:version >= 700)
    set laststatus=2
    if has('statusline')
        let g:EchoFuncShowOnStatus=1
        set statusline=%<%f\ %{EchoFuncGetStatusLine()}\ %h%m%r%=%-10.(%l,%c%V%)\ %P(%L)\ 
    endif
endif



"""""""""""""""""""""""""""""""""
" php 全能提示触发命令
"""""""""""""""""""""""""""""""""
" if !exists('g:AutoComplPop_Behavior')
" let g:AutoComplPop_Behavior = {}
" let g:AutoComplPop_Behavior['php'] = []
" call add(g:AutoComplPop_Behavior['php'], {
" \   'command'   : "\\", 
" \   'pattern'   : printf('\(->\|::\|\$\)\k\{%d,}$', 0),
" \   'repeat'    : 0,
" \})
" endif



"""""""""""""""""""""""""""""""""
" assistant 支持PHP、JS、Vim脚本
"""""""""""""""""""""""""""""""""
""" 显示当前位置函数或者变量名等关键字的原型 
"""   补全当前位置关键字 



"""""""""""""""""""""""""""""""""""
" c cpp IDE
"""""""""""""""""""""""""""""""""""
if(v:version >= 700)
set runtimepath+=/home/xxxxx/.vimhome/vim72/share/vim/cvim_IDE
set runtimepath+=/home/xxxxx/.vimhome/vim72/share/vim/cvim_IDE/after
endif



"""""""""""""""""""""""""""""""""""
" bash IDE
"""""""""""""""""""""""""""""""""""
" if(v:version >= 700)
" set runtimepath+=/home/xxxxx/.vimhome/vim72/share/vim/bash_IDE
" set runtimepath+=/home/xxxxx/.vimhome/vim72/share/vim/bash_IDE/after
" endif



"""""""""""""""""""""""""""""""""
" python IDE
"""""""""""""""""""""""""""""""""
""" Python代码检查(pyflakes)
""" 执行命令:cc,即可进行代码检查

""" VimPdb 调试Python程序
""" F5运行,F2设置断点,在运行到断点后可以用按F12可以查看
""" F7/F8 - Step into/over,F12 - Print stack trace
""" F3/Ctrl-F3 - Eval/Exec a given statement (in the current debugging context)

if(v:version >= 700)
let $PYTHONHOME="/home/xxxxx/.vimhome/python273"
" set runtimepath+=/home/xxxxx/.vimhome/vim72/share/vim/python_IDE
" set runtimepath+=/home/xxxxx/.vimhome/vim72/share/vim/python_IDE/after

" autocmd FileType python set omnifunc=pythoncomplete#Complete

let g:pydiction_location = '/home/xxxxx/.vimhome/vim72/share/vim/python_IDE/pydiction/complete-dict'
let g:pydiction_menu_height = 20
endif

autocmd FileType python set expandtab



"""""""""""""""""""""""""""""""""
" 记录文件上次编辑的位置 
"""""""""""""""""""""""""""""""""
if(v:version >= 700)
    autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif

" autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g'\"" | endif






阅读(340) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~