├── README └── plugin └── cscope_maps.vim /README: -------------------------------------------------------------------------------- 1 | This is a mirror of http://cscope.sourceforge.net/cscope_maps.vim 2 | 3 | It magically assigns awesome cscope maps to your vim sessions turning your 4 | VIM session into a superior IDE :) 5 | -------------------------------------------------------------------------------- /plugin/cscope_maps.vim: -------------------------------------------------------------------------------- 1 | """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 2 | " CSCOPE settings for vim 3 | """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 4 | " 5 | " This file contains some boilerplate settings for vim's cscope interface, 6 | " plus some keyboard mappings that I've found useful. 7 | " 8 | " USAGE: 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 11 | " 'runtimepath'. 12 | " 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). 15 | " 16 | " NOTE: 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. 20 | " 21 | " Happy cscoping, 22 | " 23 | " Jason Duell jduell@alumni.princeton.edu 2002/3/7 24 | """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 25 | 26 | 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... 29 | if has("cscope") 30 | 31 | """"""""""""" Standard cscope/vim boilerplate 32 | 33 | " use both cscope and ctag for 'ctrl-]', ':ta', and 'vim -t' 34 | set cscopetag 35 | 36 | " check cscope for definition of a symbol before checking ctags: set to 1 37 | " if you want the reverse search order. 38 | set csto=0 39 | 40 | " add any cscope database in current directory 41 | if filereadable("cscope.out") 42 | cs add cscope.out 43 | " else add the database pointed to by environment variable 44 | elseif $CSCOPE_DB != "" 45 | cs add $CSCOPE_DB 46 | endif 47 | 48 | " show msg when any other cscope db added 49 | set cscopeverbose 50 | 51 | 52 | """"""""""""" My cscope/vim key mappings 53 | " 54 | " The following maps all invoke one of the following cscope search types: 55 | " 56 | " 's' symbol: find all references to the token under cursor 57 | " 'g' global: find global definition(s) of the token under cursor 58 | " 'c' calls: find all calls to the function name under cursor 59 | " 't' text: find all instances of the text under cursor 60 | " 'e' egrep: egrep search for the word under cursor 61 | " 'f' file: open the filename under cursor 62 | " 'i' includes: find files that include the filename under cursor 63 | " 'd' called: find functions that function under cursor calls 64 | " 65 | " Below are three sets of the maps: one set that just jumps to your 66 | " search result, one that splits the existing vim window horizontally and 67 | " diplays your search result in the new window, and one that does the same 68 | " thing, but does a vertical split instead (vim 6 only). 69 | " 70 | " I've used CTRL-\ and CTRL-@ as the starting keys for these maps, as it's 71 | " unlikely that you need their default mappings (CTRL-\'s default use is 72 | " as part of CTRL-\ CTRL-N typemap, which basically just does the same 73 | " thing as hitting 'escape': CTRL-@ doesn't seem to have any default use). 74 | " If you don't like using 'CTRL-@' or CTRL-\, , you can change some or all 75 | " of these maps to use other keys. One likely candidate is 'CTRL-_' 76 | " (which also maps to CTRL-/, which is easier to type). By default it is 77 | " used to switch between Hebrew and English keyboard mode. 78 | " 79 | " All of the maps involving the macro use '^$': this is so 80 | " that searches over '#include " return only references to 81 | " 'time.h', and not 'sys/time.h', etc. (by default cscope will return all 82 | " files that contain 'time.h' as part of their name). 83 | 84 | 85 | " To do the first type of search, hit 'CTRL-\', followed by one of the 86 | " cscope search types above (s,g,c,t,e,f,i,d). The result of your cscope 87 | " search will be displayed in the current window. You can use CTRL-T to 88 | " go back to where you were before the search. 89 | " 90 | 91 | nmap s :cs find s =expand("") 92 | nmap g :cs find g =expand("") 93 | nmap c :cs find c =expand("") 94 | nmap t :cs find t =expand("") 95 | nmap e :cs find e =expand("") 96 | nmap f :cs find f =expand("") 97 | nmap i :cs find i ^=expand("")$ 98 | nmap d :cs find d =expand("") 99 | 100 | 101 | " Using 'CTRL-spacebar' (intepreted as CTRL-@ by vim) then a search type 102 | " makes the vim window split horizontally, with search result displayed in 103 | " the new window. 104 | " 105 | " (Note: earlier versions of vim may not have the :scs command, but it 106 | " can be simulated roughly via: 107 | " nmap s :cs find s =expand("") 108 | 109 | nmap s :scs find s =expand("") 110 | nmap g :scs find g =expand("") 111 | nmap c :scs find c =expand("") 112 | nmap t :scs find t =expand("") 113 | nmap e :scs find e =expand("") 114 | nmap f :scs find f =expand("") 115 | nmap i :scs find i ^=expand("")$ 116 | nmap d :scs find d =expand("") 117 | 118 | 119 | " Hitting CTRL-space *twice* before the search type does a vertical 120 | " split instead of a horizontal one (vim 6 and up only) 121 | " 122 | " (Note: you may wish to put a 'set splitright' in your .vimrc 123 | " if you prefer the new window on the right instead of the left 124 | 125 | nmap s :vert scs find s =expand("") 126 | nmap g :vert scs find g =expand("") 127 | nmap c :vert scs find c =expand("") 128 | nmap t :vert scs find t =expand("") 129 | nmap e :vert scs find e =expand("") 130 | nmap f :vert scs find f =expand("") 131 | nmap i :vert scs find i ^=expand("")$ 132 | nmap d :vert scs find d =expand("") 133 | 134 | 135 | """"""""""""" key map timeouts 136 | " 137 | " By default Vim will only wait 1 second for each keystroke in a mapping. 138 | " You may find that too short with the above typemaps. If so, you should 139 | " either turn off mapping timeouts via 'notimeout'. 140 | " 141 | "set notimeout 142 | " 143 | " Or, you can keep timeouts, by uncommenting the timeoutlen line below, 144 | " with your own personal favorite value (in milliseconds): 145 | " 146 | "set timeoutlen=4000 147 | " 148 | " Either way, since mapping timeout settings by default also set the 149 | " timeouts for multicharacter 'keys codes' (like ), you should also 150 | " set ttimeout and ttimeoutlen: otherwise, you will experience strange 151 | " delays as vim waits for a keystroke after you hit ESC (it will be 152 | " waiting to see if the ESC is actually part of a key code like ). 153 | " 154 | "set ttimeout 155 | " 156 | " personally, I find a tenth of a second to work well for key code 157 | " timeouts. If you experience problems and have a slow terminal or network 158 | " connection, set it higher. If you don't set ttimeoutlen, the value for 159 | " timeoutlent (default: 1000 = 1 second, which is sluggish) is used. 160 | " 161 | "set ttimeoutlen=100 162 | 163 | endif 164 | 165 | 166 | --------------------------------------------------------------------------------