1 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
2 " CSCOPE settings for vim
3 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
5 " This file contains some boilerplate settings for vim's cscope interface,
6 " plus some keyboard mappings that I've found useful.
9 " -- vim 6: Stick this file in your ~/.vim/plugin directory (or in a
10 " 'plugin' directory in some other directory that is in your
13 " -- vim 5: Stick this file somewhere and 'source cscope.vim' it from
14 " your ~/.vimrc file (or cut and paste it into your .vimrc).
17 " These key maps use multiple keystrokes (2 or 3 keys). If you find that vim
18 " keeps timing you out before you can complete them, try changing your timeout
19 " settings, as explained below.
23 " Jason Duell jduell@alumni.princeton.edu 2002/3/7
24 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
27 " This tests to see if vim was configured with the '--enable-cscope' option
28 " when it was compiled. If it wasn't, time to recompile vim...
31 """"""""""""" Standard cscope/vim boilerplate
33 " use both cscope and ctag for 'ctrl-]', ':ta', and 'vim -t'
36 " check cscope for definition of a symbol before checking ctags: set to 1
37 " if you want the reverse search order.
41 " add any cscope database in current directory
42 if filereadable("cscope.out")
44 " else add the database pointed to by environment variable
45 elseif $CSCOPE_DB != ""
49 " show msg when any other cscope db added
53 """"""""""""" My cscope/vim key mappings
55 " The following maps all invoke one of the following cscope search types:
57 " 's' symbol: find all references to the token under cursor
58 " 'g' global: find global definition(s) of the token under cursor
59 " 'c' calls: find all calls to the function name under cursor
60 " 't' text: find all instances of the text under cursor
61 " 'e' egrep: egrep search for the word under cursor
62 " 'f' file: open the filename under cursor
63 " 'i' includes: find files that include the filename under cursor
64 " 'd' called: find functions that function under cursor calls
66 " Below are three sets of the maps: one set that just jumps to your
67 " search result, one that splits the existing vim window horizontally and
68 " diplays your search result in the new window, and one that does the same
69 " thing, but does a vertical split instead (vim 6 only).
71 " I've used CTRL-\ and CTRL-@ as the starting keys for these maps, as it's
72 " unlikely that you need their default mappings (CTRL-\'s default use is
73 " as part of CTRL-\ CTRL-N typemap, which basically just does the same
74 " thing as hitting 'escape': CTRL-@ doesn't seem to have any default use).
75 " If you don't like using 'CTRL-@' or CTRL-\, , you can change some or all
76 " of these maps to use other keys. One likely candidate is 'CTRL-_'
77 " (which also maps to CTRL-/, which is easier to type). By default it is
78 " used to switch between Hebrew and English keyboard mode.
80 " All of the maps involving the <cfile> macro use '^<cfile>$': this is so
81 " that searches over '#include <time.h>" return only references to
82 " 'time.h', and not 'sys/time.h', etc. (by default cscope will return all
83 " files that contain 'time.h' as part of their name).
86 " To do the first type of search, hit 'CTRL-\', followed by one of the
87 " cscope search types above (s,g,c,t,e,f,i,d). The result of your cscope
88 " search will be displayed in the current window. You can use CTRL-T to
89 " go back to where you were before the search.
92 nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>
93 nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR>
94 nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR>
95 nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR>
96 nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR>
97 nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
98 nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
99 nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR>
102 " Using 'CTRL-spacebar' (intepreted as CTRL-@ by vim) then a search type
103 " makes the vim window split horizontally, with search result displayed in
106 " (Note: earlier versions of vim may not have the :scs command, but it
107 " can be simulated roughly via:
108 " nmap <C-@>s <C-W><C-S> :cs find s <C-R>=expand("<cword>")<CR><CR>
110 nmap <C-@>s :scs find s <C-R>=expand("<cword>")<CR><CR>
111 nmap <C-@>g :scs find g <C-R>=expand("<cword>")<CR><CR>
112 nmap <C-@>c :scs find c <C-R>=expand("<cword>")<CR><CR>
113 nmap <C-@>t :scs find t <C-R>=expand("<cword>")<CR><CR>
114 nmap <C-@>e :scs find e <C-R>=expand("<cword>")<CR><CR>
115 nmap <C-@>f :scs find f <C-R>=expand("<cfile>")<CR><CR>
116 nmap <C-@>i :scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
117 nmap <C-@>d :scs find d <C-R>=expand("<cword>")<CR><CR>
120 " Hitting CTRL-space *twice* before the search type does a vertical
121 " split instead of a horizontal one (vim 6 and up only)
123 " (Note: you may wish to put a 'set splitright' in your .vimrc
124 " if you prefer the new window on the right instead of the left
126 nmap <C-@><C-@>s :vert scs find s <C-R>=expand("<cword>")<CR><CR>
127 nmap <C-@><C-@>g :vert scs find g <C-R>=expand("<cword>")<CR><CR>
128 nmap <C-@><C-@>c :vert scs find c <C-R>=expand("<cword>")<CR><CR>
129 nmap <C-@><C-@>t :vert scs find t <C-R>=expand("<cword>")<CR><CR>
130 nmap <C-@><C-@>e :vert scs find e <C-R>=expand("<cword>")<CR><CR>
131 nmap <C-@><C-@>f :vert scs find f <C-R>=expand("<cfile>")<CR><CR>
132 nmap <C-@><C-@>i :vert scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
133 nmap <C-@><C-@>d :vert scs find d <C-R>=expand("<cword>")<CR><CR>
136 """"""""""""" key map timeouts
138 " By default Vim will only wait 1 second for each keystroke in a mapping.
139 " You may find that too short with the above typemaps. If so, you should
140 " either turn off mapping timeouts via 'notimeout'.
144 " Or, you can keep timeouts, by uncommenting the timeoutlen line below,
145 " with your own personal favorite value (in milliseconds):
149 " Either way, since mapping timeout settings by default also set the
150 " timeouts for multicharacter 'keys codes' (like <F1>), you should also
151 " set ttimeout and ttimeoutlen: otherwise, you will experience strange
152 " delays as vim waits for a keystroke after you hit ESC (it will be
153 " waiting to see if the ESC is actually part of a key code like <F1>).
157 " personally, I find a tenth of a second to work well for key code
158 " timeouts. If you experience problems and have a slow terminal or network
159 " connection, set it higher. If you don't set ttimeoutlen, the value for
160 " timeoutlent (default: 1000 = 1 second, which is sluggish) is used.