将vim改装成IDE编程环境

来源:互联网 发布:鼎信诺审计软件win10 编辑:程序博客网 时间:2024/04/29 15:57

(一)首先编辑~/下的.vimrc

" An example for a vimrc file."" Maintainer:Bram Moolenaar <Bram@vim.org>" Last change:2008 Dec 17"" To use it, copy it to"     for Unix and OS/2:  ~/.vimrc"      for Amiga:  s:.vimrc"  for MS-DOS and Win32:  $VIM\_vimrc"    for OpenVMS:  sys$login:.vimrc" When started as "evim", evim.vim will already have done these settings.if v:progname =~? "evim"  finishendif" Use Vim settings, rather than Vi settings (much better!)." This must be first, because it changes other options as a side effect.set nocompatible" allow backspacing over everything in insert modeset backspace=indent,eol,startif has("vms")  set nobackup" do not keep a backup file, use versions insteadelse  set backup" keep a backup fileendifset history=50" keep 50 lines of command line historyset ruler" show the cursor position all the timeset showcmd" display incomplete commandsset incsearch" do incremental searching" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries" let &guioptions = substitute(&guioptions, "t", "", "g")" Don't use Ex mode, use Q for formattingmap Q gq" CTRL-U in insert mode deletes a lot.  Use CTRL-G u to first break undo," so that you can undo CTRL-U after inserting a line break.inoremap <C-U> <C-G>u<C-U>" In many terminal emulators the mouse works just fine, thus enable it.if has('mouse')  set mouse=aendif" Switch syntax highlighting on, when the terminal has colors" Also switch on highlighting the last used search pattern.if &t_Co > 2 || has("gui_running")  syntax on  set hlsearchendif" Only do this part when compiled with support for autocommands.if has("autocmd")  " Enable file type detection.  " Use the default filetype settings, so that mail gets 'tw' set to 72,  " 'cindent' is on in C files, etc.  " Also load indent files, to automatically do language-dependent indenting.  filetype plugin indent on  " Put these in an autocmd group, so that we can delete them easily.  augroup vimrcEx  au!  " For all text files set 'textwidth' to 78 characters.  autocmd FileType text setlocal textwidth=78  " When editing a file, always jump to the last known cursor position.  " Don't do it when the position is invalid or when inside an event handler  " (happens when dropping a file on gvim).  " Also don't do it when the mark is in the first line, that is the default  " position when opening a file.  autocmd BufReadPost *    \ if line("'\"") > 1 && line("'\"") <= line("{1}quot;) |    \   exe "normal! g`\"" |    \ endif  augroup ENDelse  set autoindent" always set autoindenting onendif " has("autocmd")" Convenient command to see the difference between the current buffer and the" file it was loaded from, thus the changes you made." Only define it when not defined already.if !exists(":DiffOrig")  command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis  \ | wincmd p | diffthisendifsyntax enablesyntax onset nucolorscheme desertset tags=/home/wind/source/tagslet Tlist_Show_One_File=1let Tlist_Exit_OnlyWindow=1let g:winManagerWindowLayout='FileExplorer|TagList'nmap wm :WMToggle<cr>nmap tm :FirstExplorerWindow<cr>nmap bm :BottomExplorerWindow<cr>set cscopequickfix=s-,c-,d-,i-,t-,e-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>{1}lt;CR>nmap <C-_>d :cs find d <C-R>=expand("<cword>")<CR><CR>nmap <F6> :cn<cr>nmap <F7> :cp<cr>let g:miniBufExplMapCTabSwitchBufs = 1let g:miniBufExplMapWindowNavVim = 1let g:miniBufExplMapWindowNavArrows = 1nnoremap <silent> <F12> :A<CR>nnoremap <silent> <F3> :Grep<CR>filetype plugin indent onset completeopt=longest,menuset foldmethod=syntaxset foldlevel=100 " 启动 vim 时不要自动折叠代码"处理乱码set fileencodings=utf-8,gb2312,gbk,gb18030set termencoding=utf-8set fileformats=unixset encoding=prc


(二)然后安装ctags 和cscope (我用的是ubuntu,所以#sudo apt-get install 就搞定了)

(三)在写代码的目录下运行

ctags -Rcscope -Rbq


(四)在vi中运行

:set tag=xxx/tags:cs add xxx/cscope.out  xxx/


(五)现在你就能在代码中各种跳了
C_-  c 查找调用函数的地方
C_-  g 查找函数定义的地方
C_- c 是 CTRL +shift + -  然后快速按c
ctrl+] 跳到函数定义的地方
wm 打开taglist 和FileExplorer

效果图

在这里感谢uestc_wind的帮助

更多信息参考帖子:http://blog.csdn.net/wooin/article/details/1858917

 

原创粉丝点击