vim

vim config files
git clone https://git.bracken.jp/vim.git
Log | Files | Refs | LICENSE

cscope.vim (3081B)


      1 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
      2 " CSCOPE settings for vim
      3 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
      4 "
      5 " USAGE:
      6 " Stick this file in your ~/.vim/plugin directory (or in a
      7 " 'plugin' directory in some other directory that is in your
      8 " 'runtimepath'.
      9 "
     10 " Based off cscope_maps.vim by Jason Duell <jduell@alumni.princeton.edu>
     11 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
     12 
     13 " This tests to see if vim was configured with the '--enable-cscope' option
     14 " when it was compiled.  If it wasn't, time to recompile vim...
     15 if has("cscope")
     16 
     17   """"""""""""" Standard cscope/vim boilerplate
     18 
     19   " use both cscope and ctag for 'ctrl-]', ':ta', and 'vim -t'
     20   set cscopetag
     21 
     22   " check cscope for definition of a symbol before checking ctags: set to 1
     23   " if you want the reverse search order.
     24   set csto=0
     25 
     26   " add any cscope database in current directory
     27   if filereadable("cscope.out")
     28     cs add cscope.out
     29   " else add the database pointed to by environment variable
     30   elseif $CSCOPE_DB != ""
     31     cs add $CSCOPE_DB
     32   endif
     33 
     34   " show msg when any other cscope db added
     35   set cscopeverbose
     36 
     37 
     38   """"""""""""" My cscope/vim key mappings
     39   "
     40   " The following maps all invoke one of the following cscope search types:
     41   "
     42   "   's'   symbol: find all references to the token under cursor
     43   "   'g'   global: find global definition(s) of the token under cursor
     44   "   'c'   calls:  find all calls to the function name under cursor
     45   "   't'   text:   find all instances of the text under cursor
     46   "   'e'   egrep:  egrep search for the word under cursor
     47   "   'f'   file:   open the filename under cursor
     48   "   'i'   includes: find files that include the filename under cursor
     49   "   'd'   called: find functions that function under cursor calls
     50   "
     51   " All of the maps involving the <cfile> macro use '^<cfile>$': this is so
     52   " that searches over '#include <time.h>" return only references to
     53   " 'time.h', and not 'sys/time.h', etc. (by default cscope will return all
     54   " files that contain 'time.h' as part of their name).
     55 
     56   " To do the first type of search, hit the leader key, followed by one of
     57   " the cscope search types above (s,g,c,t,e,f,i,d).  The result of your
     58   " cscope search will be displayed in the current window.  You can use
     59   " CTRL-T to go back to where you were before the search.
     60 
     61   au FileType c,cpp,objc nmap <leader>s :cs find s <C-R>=expand("<cword>")<CR><CR>
     62   au FileType c,cpp,objc nmap <leader>g :cs find g <C-R>=expand("<cword>")<CR><CR>
     63   au FileType c,cpp,objc nmap <leader>c :cs find c <C-R>=expand("<cword>")<CR><CR>
     64   au FileType c,cpp,objc nmap <leader>t :cs find t <C-R>=expand("<cword>")<CR><CR>
     65   au FileType c,cpp,objc nmap <leader>e :cs find e <C-R>=expand("<cword>")<CR><CR>
     66   au FileType c,cpp,objc nmap <leader>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
     67   au FileType c,cpp,objc nmap <leader>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
     68   au FileType c,cpp,objc nmap <leader>d :cs find d <C-R>=expand("<cword>")<CR><CR>
     69 endif