生产力工具:ctags & cscope配合vim搭建IDE

摘要:安装:apt-get install cscopeapt-get install ctags10.141.84.119上已经装过,不需要再装了脚本从服务器上拷贝,或者把附件vim.rar解压到自己目录下cp -r /home/h00121290/.vim ~cp /home/h00121290/.vimrc ~生成数据库:在代码目录下,打开VIF7生成tagsF8生成cscope.out脚本没有做好,生成后需要重新打开vi加载数据库,有兴趣的同学可以研究研究.vimrc,自己改下快捷键介绍::cs 可以看到cscope的命令帮助cscope命令可以缩写,比如:

安装:

apt-get install cscope

apt-get install ctags

10.141.84.119上已经装过,不需要再装了

脚本从服务器上拷贝,或者把附件vim.rar解压到自己目录下

cp -r /home/h00121290/.vim ~

cp /home/h00121290/.vimrc ~

生成数据库:

在代码目录下,打开VI

F7    生成tags

F8    生成cscope.out

脚本没有做好,生成后需要重新打开vi加载数据库,有兴趣的同学可以研究研究.vimrc,自己改下

快捷键介绍:

:cs    可以看到cscope的命令帮助

cscope命令可以缩写,比如:打开文件board-k3v2oem1.c,可以输入:cs f f oem,然后选择对应的文件

ctrl+\+'x'    按照“:cs f 'x' 光标所在符号”方式查找,'x'是c|d|e|f|g|i|s|t之一,参阅cscope命令帮助

ctrl+]    跳转到光标所在符号定义

ctrl+t    回跳到跳转前

.vimrc文件内容替换

"==============================================================================
"        Filename: vimrc
"        Author: zrainx
"        Email: zrainx@gmail.com
"        Created: 2008-04-10
"===============================================================================
 set fileencodings=utf-8,gbk,gb2312
 set guifont=Luxi\ Mono\ 9   " set font,font name,font size
 set tabstop=4       " set width of tab
 set backspace=2     " set backspace
 set nu!             " display line number
 "set wrap           " wrap
 set nowrap         "  no wrap
 set linebreak       " wrap between whole word
 set whichwrap=b,s,<,>,[,]       " curser could goto another line when it access the 
                                 " the start or end of line
 set hidden          " hidden the unsave buffer
 set scrolloff=5
 set nobackup        " forbid backup file
 "set ff=unix         " open file as unix format
 "-------------------------------------------------------------------------------
"  some additional hot keys
"-------------------------------------------------------------------------------
"    F2  -  toggle the pastemode
"    F3  -  toggle line numbers
"    F5  -  make
"    F6  -  list all errors  
"    F7  -  cteate tagfile in current directory  
"    F8  -  create scscope.out in current directory      
"
"-------------------------------------------------------------------------------
"
map     <silent> <F3>  <ESC>:let &number=1-&number<CR>
map     <silent> <F6>  <ESC>:copen<CR>
map     <silent> <F7>  <ESC>:!ctags --sort=foldcase -R . <CR>
map     <silent> <F8>  <ESC>:!cscope -bRk <CR>
imap    <silent> <F3>  <ESC>:let &number=1-&number<CR>
imap    <silent> <F6>  <ESC>:copen<CR>
imap    <silent> <F7>  <ESC>:!ctags --sort=foldcase -R . <CR>
imap    <silent> <F8>  <ESC>:!cscope -b -i -c <CR>


 "--------------------------------------------------------------------------------
 " setting on searching and replace
 "--------------------------------------------------------------------------------
 set hlsearch        " Highlight search results
                      
 "set gdefault        " replace all the matching words at current line,instead
                      " of replacing the first matching one
 
 set incsearch        " While typing a search command, show immediately where the 
                      " so far typed pattern matches.
 set ignorecase      " Ignore case in search patterns.
 set smartcase       " Override the 'ignorecase' option if the search pattern
                     " contains upper case characters.
  
  "--------------------------------------------------------------------------------
 " setting on status bar
 "--------------------------------------------------------------------------------
 set statusline=[%F]%y%r%m%*%=[Line:%l/%L,Column:%c][%p%%]
 set laststatus=2    " always show the status line
 set ruler           " display the location of cusor at the right bottom of the 
                     " status bar
 
 "--------------------------------------------------------------------------------
 " simulate the short cut key of MS Windows
 "--------------------------------------------------------------------------------
   nmap <C-a> ggvG$  "select all by input Ctrl-a
 "--------------------------------------------------------------------------------
 " setting on program
 "--------------------------------------------------------------------------------
 "set completeopt=longest,menu   " switch off the preview window of smart completion
 filetype plugin indent on        " smart indent according the file type 
 syntax on                        " syntax highlighting
 set mouse=                       " disable the use of the mouse.
 set showmatch                    "if you have just typed parens/bracket/comment
                                "opening/etc, 
                                "makes cursor to jump shortly to its counterpart. 
 set smartindent                " smart indent
 set shiftwidth=4               " the length of smart indent eguals to 4 space
 set autoindent                 " auto indent
 "set backspace=indent,eol,start " Influences the working of <BS>, <Del>, CTRL-W
                           " and CTRL-U in Insert mode. This is a list of items,
                      " separated by commas. Each item allows a way to backspace
                      " over something.

 colorscheme desert  " choose the desert color theme
 "colorscheme molokai   " choose the molokai color theme
 "colorscheme  evening  " choose the evening color theme
 "--------------------------------------------------------------------------------
 " folding code
 "--------------------------------------------------------------------------------
set tabstop=4 
set softtabstop=4 
set expandtab 
set foldcolumn=1  " Optional 
 
 "--------------------------------------------------------------------------------
 " short cut key on windows operation
 "--------------------------------------------------------------------------------
 nmap  wv     <C-w>v     " splite current window vertically
 nmap  wc     <C-w>c     " close current window
 nmap  ws     <C-w>s     " splite current window horizontally
 nmap  wx :WinFullScreen<CR> " Open and close win_full_screen.vim


 "###############################################################################
 " The following is the Plugins' setting
 "###############################################################################
 
 "--------------------------------------------------------------------------------
 " TagList :Tlist
 "--------------------------------------------------------------------------------
 nmap wt  :TlistToggle<CR> " Toggle TagList
 let Tlist_Show_One_File = 1
 let Tlist_Exit_OnlyWindow = 1
 
 "--------------------------------------------------------------------------------
 " Source Explorer
 "--------------------------------------------------------------------------------
 ""  The switch of the Source Explorer

     nmap we :SrcExplToggle<CR> " Toggle SrcExplore
    
     " Set the height of Source Explorer window
     
     let g:SrcExpl_winHeight = 12
     
     " Set 100 ms for refreshing the Source Explorer
     
     let g:SrcExpl_refreshTime = 100
          
     " Set "Enter" key to jump into the exact definition context
     
     "let g:SrcExpl_jumpKey = "<CR>"
       
     " Set "Space" key for back from the definition context
        
     "let g:SrcExpl_gobackKey = "<SPACE>"
 

 "--------------------------------------------------------------------------------
 " Grep
 "--------------------------------------------------------------------------------
 "直接按下\g来查找光标所在的字符???
 nnoremap <Leader>g     <ESC> :Rgrep<CR>

 "--------------------------------------------------------------------------------
 " cscope map
 "---------------------------------------------------------------------------------
 "
    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>$<CR>
    nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR>	

"--------------------------------------------------
" CCTree 
"-------------------------------------------------- 
"
   let g:CCTreeOrientation = "topright"

"--------------------------------------------------------------------------------
 " neocomplcache
 "---------------------------------------------------------------------------------
 "
    nmap <F2> :NeoComplCacheToggle<CR>  " Toggle NeoComplCache
 
    " Disable AutoComplPop.
	let g:acp_enableAtStartup = 0
	" Use neocomplcache.
	let g:neocomplcache_enable_at_startup = 1
	" Use smartcase.
	let g:neocomplcache_enable_smart_case = 1
	" Use camel case completion.
	let g:neocomplcache_enable_camel_case_completion = 1
	" Use underbar completion.
	let g:neocomplcache_enable_underbar_completion = 1
	" Set minimum syntax keyword length.
	let g:neocomplcache_min_syntax_length = 3
	let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*'
	
	" Define dictionary.
	let g:neocomplcache_dictionary_filetype_lists = {
	    \ 'default' : '',
	    \ 'vimshell' : $HOME.'/.vimshell_hist',
	    \ 'scheme' : $HOME.'/.gosh_completions'
	        \ }
	
	" Define keyword.
	if !exists('g:neocomplcache_keyword_patterns')
	    let g:neocomplcache_keyword_patterns = {}
	endif
	let g:neocomplcache_keyword_patterns['default'] = '\h\w*'
	
	" Plugin key-mappings.
	imap <C-k>     <Plug>(neocomplcache_snippets_expand)
	smap <C-k>     <Plug>(neocomplcache_snippets_expand)
	inoremap <expr><C-g>     neocomplcache#undo_completion()
	inoremap <expr><C-l>     neocomplcache#complete_common_string()
	
	" SuperTab like snippets behavior.
	"imap <expr><TAB> neocomplcache#sources#snippets_complete#expandable() ? 
	"\<Plug>(neocomplcache_snippets_expand)" : pumvisible() ? "\<C-n>" : "\<TAB>"
	
	" Recommended key-mappings.
	" <CR>: close popup and save indent.
	inoremap <expr><CR>  neocomplcache#close_popup() . "\<CR>"
	" <TAB>: completion.
	inoremap <expr><TAB>  pumvisible() ? "\<C-n>" : "\<TAB>"
	" <C-h>, <BS>: close popup and delete backword char.
	inoremap <expr><C-h> neocomplcache#smart_close_popup()."\<C-h>"
	inoremap <expr><BS> neocomplcache#smart_close_popup()."\<C-h>"
	inoremap <expr><C-y>  neocomplcache#close_popup()
	inoremap <expr><C-e>  neocomplcache#cancel_popup()
	
	" For cursor moving in insert mode(Not recommended)
	inoremap <expr><Left>  neocomplcache#close_popup() . "\<Left>"
	inoremap <expr><Right> neocomplcache#close_popup() . "\<Right>"
	inoremap <expr><Up>    neocomplcache#close_popup() . "\<Up>"
	inoremap <expr><Down>  neocomplcache#close_popup() . "\<Down>"
	
	" AutoComplPop like behavior.
	"let g:neocomplcache_enable_auto_select = 1
	
	" Shell like behavior(not recommended).
	"set completeopt+=longest
	"let g:neocomplcache_enable_auto_select = 1
	"let g:neocomplcache_disable_auto_complete = 1
	"inoremap <expr><TAB>  pumvisible() ? "\<Down>" : "\<C-x>\<C-u>"
	"inoremap <expr><CR>  neocomplcache#smart_close_popup() . "\<CR>"
	
	" Enable omni completion.
	autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
	autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
	autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
	autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
	autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
	
	" Enable heavy omni completion.
	if !exists('g:neocomplcache_omni_patterns')
	  let g:neocomplcache_omni_patterns = {}
	endif
	let g:neocomplcache_omni_patterns.ruby = '[^. *\t]\.\h\w*\|\h\w*::'
	"autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete
	let g:neocomplcache_omni_patterns.php = '[^. \t]->\h\w*\|\h\w*::'
	let g:neocomplcache_omni_patterns.c = '\%(\.\|->\)\h\w*'
	let g:neocomplcache_omni_patterns.cpp = '\h\w*\%(\.\|->\)\h\w*\|\h\w*::'
	
	" For snippet_complete marker.
	if has('conceal')
	  set conceallevel=2 concealcursor=i
	endif

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值