Christian Brabandt | 1c5728e | 2024-05-11 11:12:40 +0200 | [diff] [blame] | 1 | *if_cscop.txt* For Vim version 9.1. Last change: 2024 May 11 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 2 | |
| 3 | |
| 4 | VIM REFERENCE MANUAL by Andy Kahn |
| 5 | |
| 6 | *cscope* *Cscope* |
| 7 | This document explains how to use Vim's cscope interface. |
| 8 | |
| 9 | Cscope is a tool like ctags, but think of it as ctags on steroids since it |
| 10 | does a lot more than what ctags provides. In Vim, jumping to a result from |
| 11 | a cscope query is just like jumping to any tag; it is saved on the tag stack |
| 12 | so that with the right keyboard mappings, you can jump back and forth between |
| 13 | functions as you normally would with |tags|. |
| 14 | |
| 15 | 1. Cscope introduction |cscope-intro| |
| 16 | 2. Cscope related commands |cscope-commands| |
| 17 | 3. Cscope options |cscope-options| |
| 18 | 4. How to use cscope in Vim |cscope-howtouse| |
| 19 | 5. Limitations |cscope-limitations| |
| 20 | 6. Suggested usage |cscope-suggestions| |
| 21 | 7. Availability & Information |cscope-info| |
| 22 | |
| 23 | This is currently for Unix and Win32 only. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 24 | |
| 25 | ============================================================================== |
| 26 | 1. Cscope introduction *cscope-intro* |
| 27 | |
| 28 | The following text is taken from a version of the cscope man page: |
| 29 | |
| 30 | ----- |
| 31 | |
| 32 | Cscope is an interactive screen-oriented tool that helps you: |
| 33 | |
| 34 | Learn how a C program works without endless flipping through a thick |
| 35 | listing. |
| 36 | |
| 37 | Locate the section of code to change to fix a bug without having to |
| 38 | learn the entire program. |
| 39 | |
| 40 | Examine the effect of a proposed change such as adding a value to an |
| 41 | enum variable. |
| 42 | |
| 43 | Verify that a change has been made in all source files such as adding |
| 44 | an argument to an existing function. |
| 45 | |
| 46 | Rename a global variable in all source files. |
| 47 | |
| 48 | Change a constant to a preprocessor symbol in selected lines of files. |
| 49 | |
| 50 | It is designed to answer questions like: |
| 51 | Where is this symbol used? |
| 52 | Where is it defined? |
| 53 | Where did this variable get its value? |
| 54 | What is this global symbol's definition? |
| 55 | Where is this function in the source files? |
| 56 | What functions call this function? |
| 57 | What functions are called by this function? |
| 58 | Where does the message "out of space" come from? |
| 59 | Where is this source file in the directory structure? |
| 60 | What files include this header file? |
| 61 | |
| 62 | Cscope answers these questions from a symbol database that it builds the |
| 63 | first time it is used on the source files. On a subsequent call, cscope |
| 64 | rebuilds the database only if a source file has changed or the list of |
| 65 | source files is different. When the database is rebuilt the data for the |
| 66 | unchanged files is copied from the old database, which makes rebuilding |
| 67 | much faster than the initial build. |
| 68 | |
| 69 | ----- |
| 70 | |
| 71 | When cscope is normally invoked, you will get a full-screen selection |
| 72 | screen allowing you to make a query for one of the above questions. |
| 73 | However, once a match is found to your query and you have entered your |
| 74 | text editor to edit the source file containing match, you cannot simply |
| 75 | jump from tag to tag as you normally would with vi's Ctrl-] or :tag |
| 76 | command. |
| 77 | |
| 78 | Vim's cscope interface is done by invoking cscope with its line-oriented |
| 79 | interface, and then parsing the output returned from a query. The end |
| 80 | result is that cscope query results become just like regular tags, so |
| 81 | you can jump to them just like you do with normal tags (Ctrl-] or :tag) |
| 82 | and then go back by popping off the tagstack with Ctrl-T. (Please note |
| 83 | however, that you don't actually jump to a cscope tag simply by doing |
| 84 | Ctrl-] or :tag without remapping these commands or setting an option. |
| 85 | See the remaining sections on how the cscope interface works and for |
| 86 | suggested use.) |
| 87 | |
| 88 | |
| 89 | ============================================================================== |
| 90 | 2. Cscope related commands *cscope-commands* |
| 91 | |
Bram Moolenaar | 2f0936c | 2022-01-08 21:51:59 +0000 | [diff] [blame] | 92 | *:cscope* *:cs* *:scs* *:scscope* *E259* *E262* *E560* *E561* |
Bram Moolenaar | 74675a6 | 2017-07-15 13:53:23 +0200 | [diff] [blame] | 93 | All cscope commands are accessed through suboptions to the cscope commands. |
| 94 | `:cscope` or `:cs` is the main command |
| 95 | `:scscope` or `:scs` does the same and splits the window |
| 96 | `:lcscope` or `:lcs` uses the location list, see |:lcscope| |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 97 | |
| 98 | The available subcommands are: |
| 99 | |
Bram Moolenaar | aa3b15d | 2016-04-21 08:53:19 +0200 | [diff] [blame] | 100 | *E563* *E564* *E566* *E568* *E622* *E623* *E625* |
| 101 | *E626* *E609* |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 102 | add : Add a new cscope database/connection. |
| 103 | |
| 104 | USAGE :cs add {file|dir} [pre-path] [flags] |
| 105 | |
| 106 | [pre-path] is the pathname used with the -P command to cscope. |
| 107 | |
| 108 | [flags] are any additional flags you want to pass to cscope. |
| 109 | |
| 110 | EXAMPLES > |
| 111 | :cscope add /usr/local/cdb/cscope.out |
| 112 | :cscope add /projects/vim/cscope.out /usr/local/vim |
| 113 | :cscope add cscope.out /usr/local/vim -C |
| 114 | < |
Bram Moolenaar | 4a74803 | 2010-09-30 21:47:56 +0200 | [diff] [blame] | 115 | *cscope-find* *cs-find* *E567* |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 116 | find : Query cscope. All cscope query options are available |
| 117 | except option #5 ("Change this grep pattern"). |
| 118 | |
| 119 | USAGE :cs find {querytype} {name} |
| 120 | |
| 121 | {querytype} corresponds to the actual cscope line |
| 122 | interface numbers as well as default nvi commands: |
| 123 | |
| 124 | 0 or s: Find this C symbol |
| 125 | 1 or g: Find this definition |
| 126 | 2 or d: Find functions called by this function |
| 127 | 3 or c: Find functions calling this function |
| 128 | 4 or t: Find this text string |
| 129 | 6 or e: Find this egrep pattern |
| 130 | 7 or f: Find this file |
| 131 | 8 or i: Find files #including this file |
Bram Moolenaar | 802a0d9 | 2016-06-26 16:17:58 +0200 | [diff] [blame] | 132 | 9 or a: Find places where this symbol is assigned a value |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 133 | |
Bram Moolenaar | 80b6a0e | 2009-03-18 13:32:24 +0000 | [diff] [blame] | 134 | For all types, except 4 and 6, leading white space for {name} is |
| 135 | removed. For 4 and 6 there is exactly one space between {querytype} |
| 136 | and {name}. Further white space is included in {name}. |
| 137 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 138 | EXAMPLES > |
| 139 | :cscope find c vim_free |
Bram Moolenaar | 80b6a0e | 2009-03-18 13:32:24 +0000 | [diff] [blame] | 140 | :cscope find 3 vim_free |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 141 | < |
Bram Moolenaar | 80b6a0e | 2009-03-18 13:32:24 +0000 | [diff] [blame] | 142 | These two examples perform the same query: functions calling |
| 143 | "vim_free". > |
| 144 | |
| 145 | :cscope find t initOnce |
| 146 | :cscope find t initOnce |
| 147 | < |
| 148 | The first one searches for the text "initOnce", the second one for |
| 149 | " initOnce". > |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 150 | |
| 151 | :cscope find 0 DEFAULT_TERM |
| 152 | < |
| 153 | Executing this example on the source code for Vim 5.1 produces the |
| 154 | following output: |
| 155 | |
| 156 | Cscope tag: DEFAULT_TERM |
| 157 | # line filename / context / line |
| 158 | 1 1009 vim-5.1-gtk/src/term.c <<GLOBAL>> |
| 159 | #define DEFAULT_TERM (char_u *)"amiga" |
| 160 | 2 1013 vim-5.1-gtk/src/term.c <<GLOBAL>> |
| 161 | #define DEFAULT_TERM (char_u *)"win32" |
| 162 | 3 1017 vim-5.1-gtk/src/term.c <<GLOBAL>> |
| 163 | #define DEFAULT_TERM (char_u *)"pcterm" |
| 164 | 4 1021 vim-5.1-gtk/src/term.c <<GLOBAL>> |
| 165 | #define DEFAULT_TERM (char_u *)"ansi" |
| 166 | 5 1025 vim-5.1-gtk/src/term.c <<GLOBAL>> |
| 167 | #define DEFAULT_TERM (char_u *)"vt52" |
| 168 | 6 1029 vim-5.1-gtk/src/term.c <<GLOBAL>> |
| 169 | #define DEFAULT_TERM (char_u *)"os2ansi" |
| 170 | 7 1033 vim-5.1-gtk/src/term.c <<GLOBAL>> |
| 171 | #define DEFAULT_TERM (char_u *)"ansi" |
| 172 | 8 1037 vim-5.1-gtk/src/term.c <<GLOBAL>> |
| 173 | # undef DEFAULT_TERM |
| 174 | 9 1038 vim-5.1-gtk/src/term.c <<GLOBAL>> |
| 175 | #define DEFAULT_TERM (char_u *)"beos-ansi" |
| 176 | 10 1042 vim-5.1-gtk/src/term.c <<GLOBAL>> |
| 177 | #define DEFAULT_TERM (char_u *)"mac-ansi" |
| 178 | 11 1335 vim-5.1-gtk/src/term.c <<set_termname>> |
| 179 | term = DEFAULT_TERM; |
| 180 | 12 1459 vim-5.1-gtk/src/term.c <<set_termname>> |
| 181 | if (STRCMP(term, DEFAULT_TERM)) |
| 182 | 13 1826 vim-5.1-gtk/src/term.c <<termcapinit>> |
| 183 | term = DEFAULT_TERM; |
| 184 | 14 1833 vim-5.1-gtk/src/term.c <<termcapinit>> |
| 185 | term = DEFAULT_TERM; |
| 186 | 15 3635 vim-5.1-gtk/src/term.c <<update_tcap>> |
| 187 | p = find_builtin_term(DEFAULT_TERM); |
| 188 | Enter nr of choice (<CR> to abort): |
| 189 | |
| 190 | The output shows several pieces of information: |
| 191 | 1. The tag number (there are 15 in this example). |
| 192 | 2. The line number where the tag occurs. |
| 193 | 3. The filename where the tag occurs. |
| 194 | 4. The context of the tag (e.g., global, or the function name). |
| 195 | 5. The line from the file itself. |
| 196 | |
| 197 | help : Show a brief synopsis. |
| 198 | |
| 199 | USAGE :cs help |
| 200 | |
Bram Moolenaar | 4a74803 | 2010-09-30 21:47:56 +0200 | [diff] [blame] | 201 | *E261* |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 202 | kill : Kill a cscope connection (or kill all cscope connections). |
| 203 | |
| 204 | USAGE :cs kill {num|partial_name} |
| 205 | |
| 206 | To kill a cscope connection, the connection number or a partial |
| 207 | name must be specified. The partial name is simply any part of |
| 208 | the pathname of the cscope database. Kill a cscope connection |
| 209 | using the partial name with caution! |
| 210 | |
| 211 | If the specified connection number is -1, then _ALL_ cscope |
| 212 | connections will be killed. |
| 213 | |
| 214 | reset : Reinit all cscope connections. |
| 215 | |
| 216 | USAGE :cs reset |
| 217 | |
| 218 | show : Show cscope connections. |
| 219 | |
| 220 | USAGE :cs show |
| 221 | |
Bram Moolenaar | c7453f5 | 2006-02-10 23:20:28 +0000 | [diff] [blame] | 222 | *:lcscope* *:lcs* |
| 223 | This command is same as the ":cscope" command, except when the |
| 224 | 'cscopequickfix' option is set, the location list for the current window is |
| 225 | used instead of the quickfix list to show the cscope results. |
| 226 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 227 | *:cstag* *E257* *E562* |
| 228 | If you use cscope as well as ctags, |:cstag| allows you to search one or |
| 229 | the other before making a jump. For example, you can choose to first |
| 230 | search your cscope database(s) for a match, and if one is not found, then |
| 231 | your tags file(s) will be searched. The order in which this happens |
| 232 | is determined by the value of |csto|. See |cscope-options| for more |
| 233 | details. |
| 234 | |
| 235 | |:cstag| performs the equivalent of ":cs find g" on the identifier when |
| 236 | searching through the cscope database(s). |
| 237 | |
| 238 | |:cstag| performs the equivalent of |:tjump| on the identifier when searching |
| 239 | through your tags file(s). |
| 240 | |
| 241 | |
| 242 | ============================================================================== |
| 243 | 3. Cscope options *cscope-options* |
| 244 | |
| 245 | Use the |:set| command to set all cscope options. Ideally, you would do |
| 246 | this in one of your startup files (e.g., .vimrc). Some cscope related |
| 247 | variables are only valid within |.vimrc|. Setting them after vim has |
| 248 | started will have no effect! |
| 249 | |
| 250 | *cscopeprg* *csprg* |
| 251 | 'cscopeprg' specifies the command to execute cscope. The default is |
| 252 | "cscope". For example: > |
| 253 | :set csprg=/usr/local/bin/cscope |
| 254 | < |
| 255 | *cscopequickfix* *csqf* *E469* |
| 256 | {not available when compiled without the |+quickfix| feature} |
| 257 | 'cscopequickfix' specifies whether to use quickfix window to show cscope |
Bram Moolenaar | 402d2fe | 2005-04-15 21:00:38 +0000 | [diff] [blame] | 258 | results. This is a list of comma-separated values. Each item consists of |
Bram Moolenaar | 802a0d9 | 2016-06-26 16:17:58 +0200 | [diff] [blame] | 259 | |cscope-find| command (s, g, d, c, t, e, f, i or a) and flag (+, - or 0). |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 260 | '+' indicates that results must be appended to quickfix window, |
| 261 | '-' implies previous results clearance, '0' or command absence - don't use |
Bram Moolenaar | 402d2fe | 2005-04-15 21:00:38 +0000 | [diff] [blame] | 262 | quickfix. Search is performed from start until first command occurrence. |
| 263 | The default value is "" (don't use quickfix anyway). The following value |
Bram Moolenaar | 009b259 | 2004-10-24 19:18:58 +0000 | [diff] [blame] | 264 | seems to be useful: > |
Bram Moolenaar | 802a0d9 | 2016-06-26 16:17:58 +0200 | [diff] [blame] | 265 | :set cscopequickfix=s-,c-,d-,i-,t-,e-,a- |
Bram Moolenaar | 009b259 | 2004-10-24 19:18:58 +0000 | [diff] [blame] | 266 | < |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 267 | *cscopetag* *cst* |
Bram Moolenaar | 251e191 | 2011-06-19 05:09:16 +0200 | [diff] [blame] | 268 | If 'cscopetag' is set, the commands ":tag" and CTRL-] as well as "vim -t" |
| 269 | will always use |:cstag| instead of the default :tag behavior. Effectively, |
| 270 | by setting 'cst', you will always search your cscope databases as well as |
| 271 | your tag files. The default is off. Examples: > |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 272 | :set cst |
| 273 | :set nocst |
| 274 | < |
Bram Moolenaar | 2f982e4 | 2011-06-12 20:42:22 +0200 | [diff] [blame] | 275 | *cscoperelative* *csre* |
Bram Moolenaar | 251e191 | 2011-06-19 05:09:16 +0200 | [diff] [blame] | 276 | If 'cscoperelative' is set, then in absence of a prefix given to cscope |
| 277 | (prefix is the argument of -P option of cscope), basename of cscope.out |
| 278 | location (usually the project root directory) will be used as the prefix |
| 279 | to construct an absolute path. The default is off. Note: This option is |
| 280 | only effective when cscope (cscopeprg) is initialized without a prefix |
| 281 | path (-P). Examples: > |
Bram Moolenaar | 2f982e4 | 2011-06-12 20:42:22 +0200 | [diff] [blame] | 282 | :set csre |
| 283 | :set nocsre |
| 284 | < |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 285 | *cscopetagorder* *csto* |
| 286 | The value of 'csto' determines the order in which |:cstag| performs a search. |
| 287 | If 'csto' is set to zero, cscope database(s) are searched first, followed |
| 288 | by tag file(s) if cscope did not return any matches. If 'csto' is set to |
| 289 | one, tag file(s) are searched before cscope database(s). The default is zero. |
| 290 | Examples: > |
| 291 | :set csto=0 |
| 292 | :set csto=1 |
| 293 | < |
| 294 | *cscopeverbose* *csverb* |
| 295 | If 'cscopeverbose' is not set (the default), messages will not be printed |
| 296 | indicating success or failure when adding a cscope database. Ideally, you |
| 297 | should reset this option in your |.vimrc| before adding any cscope databases, |
| 298 | and after adding them, set it. From then on, when you add more databases |
| 299 | within Vim, you will get a (hopefully) useful message should the database fail |
| 300 | to be added. Examples: > |
| 301 | :set csverb |
| 302 | :set nocsverb |
| 303 | < |
| 304 | *cscopepathcomp* *cspc* |
| 305 | The value of 'cspc' determines how many components of a file's path to |
| 306 | display. With the default value of zero the entire path will be displayed. |
| 307 | The value one will display only the filename with no path. Other values |
| 308 | display that many components. For example: > |
| 309 | :set cspc=3 |
| 310 | will display the last 3 components of the file's path, including the file |
| 311 | name itself. |
| 312 | |
| 313 | ============================================================================== |
| 314 | 4. How to use cscope in Vim *cscope-howtouse* |
| 315 | |
| 316 | The first thing you need to do is to build a cscope database for your |
| 317 | source files. For the most basic case, simply do "cscope -b". Please |
| 318 | refer to the cscope man page for more details. |
| 319 | |
| 320 | Assuming you have a cscope database, you need to "add" the database to Vim. |
| 321 | This establishes a cscope "connection" and makes it available for Vim to use. |
| 322 | You can do this in your .vimrc file, or you can do it manually after starting |
| 323 | vim. For example, to add the cscope database "cscope.out", you would do: |
| 324 | |
| 325 | :cs add cscope.out |
| 326 | |
| 327 | You can double-check the result of this by executing ":cs show". This will |
| 328 | produce output which looks like this: |
| 329 | |
| 330 | # pid database name prepend path |
| 331 | 0 28806 cscope.out <none> |
| 332 | |
| 333 | Note: |
| 334 | Because of the Microsoft RTL limitations, Win32 version shows 0 instead |
| 335 | of the real pid. |
| 336 | |
| 337 | Once a cscope connection is established, you can make queries to cscope and |
| 338 | the results will be printed to you. Queries are made using the command |
| 339 | ":cs find". For example: |
| 340 | |
| 341 | :cs find g ALIGN_SIZE |
| 342 | |
| 343 | This can get a little cumbersome since one ends up doing a significant |
| 344 | amount of typing. Fortunately, there are ways around this by mapping |
| 345 | shortcut keys. See |cscope-suggestions| for suggested usage. |
| 346 | |
| 347 | If the results return only one match, you will automatically be taken to it. |
| 348 | If there is more than one match, you will be given a selection screen to pick |
| 349 | the match you want to go to. After you have jumped to the new location, |
| 350 | simply hit Ctrl-T to get back to the previous one. |
| 351 | |
| 352 | |
| 353 | ============================================================================== |
| 354 | 5. Limitations *cscope-limitations* |
| 355 | |
| 356 | Cscope support for Vim is only available on systems that support these four |
| 357 | system calls: fork(), pipe(), execl(), waitpid(). This means it is mostly |
| 358 | limited to Unix systems. |
| 359 | |
| 360 | Additionally Cscope support works for Win32. For more information and a |
Christian Brabandt | 1c5728e | 2024-05-11 11:12:40 +0200 | [diff] [blame] | 361 | cscope version for Win32 see (link seems dead): |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 362 | |
| 363 | http://iamphet.nm.ru/cscope/index.html |
| 364 | |
Bram Moolenaar | 5eb86f9 | 2004-07-26 12:53:41 +0000 | [diff] [blame] | 365 | The DJGPP-built version from http://cscope.sourceforge.net is known to not |
| 366 | work with Vim. |
| 367 | |
Bram Moolenaar | 9fa49da | 2009-07-10 13:11:26 +0000 | [diff] [blame] | 368 | Hard-coded limitation: doing a |:tjump| when |:cstag| searches the tag files |
| 369 | is not configurable (e.g., you can't do a tselect instead). |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 370 | |
| 371 | ============================================================================== |
| 372 | 6. Suggested usage *cscope-suggestions* |
| 373 | |
| 374 | Put these entries in your .vimrc (adjust the pathname accordingly to your |
| 375 | setup): > |
| 376 | |
| 377 | if has("cscope") |
| 378 | set csprg=/usr/local/bin/cscope |
| 379 | set csto=0 |
| 380 | set cst |
| 381 | set nocsverb |
| 382 | " add any database in current directory |
| 383 | if filereadable("cscope.out") |
| 384 | cs add cscope.out |
| 385 | " else add database pointed to by environment |
| 386 | elseif $CSCOPE_DB != "" |
| 387 | cs add $CSCOPE_DB |
| 388 | endif |
| 389 | set csverb |
| 390 | endif |
| 391 | |
| 392 | By setting 'cscopetag', we have effectively replaced all instances of the :tag |
| 393 | command with :cstag. This includes :tag, Ctrl-], and "vim -t". In doing |
| 394 | this, the regular tag command not only searches your ctags generated tag |
| 395 | files, but your cscope databases as well. |
| 396 | |
| 397 | Some users may want to keep the regular tag behavior and have a different |
| 398 | shortcut to access :cstag. For example, one could map Ctrl-_ (underscore) |
| 399 | to :cstag with the following command: > |
| 400 | |
| 401 | map <C-_> :cstag <C-R>=expand("<cword>")<CR><CR> |
| 402 | |
| 403 | A couple of very commonly used cscope queries (using ":cs find") is to |
| 404 | find all functions calling a certain function and to find all occurrences |
| 405 | of a particular C symbol. To do this, you can use these mappings as an |
| 406 | example: > |
| 407 | |
| 408 | map g<C-]> :cs find 3 <C-R>=expand("<cword>")<CR><CR> |
| 409 | map g<C-\> :cs find 0 <C-R>=expand("<cword>")<CR><CR> |
| 410 | |
| 411 | These mappings for Ctrl-] (right bracket) and Ctrl-\ (backslash) allow you to |
| 412 | place your cursor over the function name or C symbol and quickly query cscope |
| 413 | for any matches. |
| 414 | |
| 415 | Or you may use the following scheme, inspired by Vim/Cscope tutorial from |
| 416 | Cscope Home Page (http://cscope.sourceforge.net/): > |
| 417 | |
| 418 | nmap <C-_>s :cs find s <C-R>=expand("<cword>")<CR><CR> |
| 419 | nmap <C-_>g :cs find g <C-R>=expand("<cword>")<CR><CR> |
| 420 | nmap <C-_>c :cs find c <C-R>=expand("<cword>")<CR><CR> |
| 421 | nmap <C-_>t :cs find t <C-R>=expand("<cword>")<CR><CR> |
| 422 | nmap <C-_>e :cs find e <C-R>=expand("<cword>")<CR><CR> |
| 423 | nmap <C-_>f :cs find f <C-R>=expand("<cfile>")<CR><CR> |
| 424 | nmap <C-_>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR> |
| 425 | nmap <C-_>d :cs find d <C-R>=expand("<cword>")<CR><CR> |
Bram Moolenaar | 802a0d9 | 2016-06-26 16:17:58 +0200 | [diff] [blame] | 426 | nmap <C-_>a :cs find a <C-R>=expand("<cword>")<CR><CR> |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 427 | |
| 428 | " Using 'CTRL-spacebar' then a search type makes the vim window |
| 429 | " split horizontally, with search result displayed in |
| 430 | " the new window. |
| 431 | |
| 432 | nmap <C-Space>s :scs find s <C-R>=expand("<cword>")<CR><CR> |
| 433 | nmap <C-Space>g :scs find g <C-R>=expand("<cword>")<CR><CR> |
| 434 | nmap <C-Space>c :scs find c <C-R>=expand("<cword>")<CR><CR> |
| 435 | nmap <C-Space>t :scs find t <C-R>=expand("<cword>")<CR><CR> |
| 436 | nmap <C-Space>e :scs find e <C-R>=expand("<cword>")<CR><CR> |
| 437 | nmap <C-Space>f :scs find f <C-R>=expand("<cfile>")<CR><CR> |
| 438 | nmap <C-Space>i :scs find i ^<C-R>=expand("<cfile>")<CR>$<CR> |
| 439 | nmap <C-Space>d :scs find d <C-R>=expand("<cword>")<CR><CR> |
Bram Moolenaar | 802a0d9 | 2016-06-26 16:17:58 +0200 | [diff] [blame] | 440 | nmap <C-Space>a :scs find a <C-R>=expand("<cword>")<CR><CR> |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 441 | |
| 442 | " Hitting CTRL-space *twice* before the search type does a vertical |
| 443 | " split instead of a horizontal one |
| 444 | |
| 445 | nmap <C-Space><C-Space>s |
| 446 | \:vert scs find s <C-R>=expand("<cword>")<CR><CR> |
| 447 | nmap <C-Space><C-Space>g |
| 448 | \:vert scs find g <C-R>=expand("<cword>")<CR><CR> |
| 449 | nmap <C-Space><C-Space>c |
| 450 | \:vert scs find c <C-R>=expand("<cword>")<CR><CR> |
| 451 | nmap <C-Space><C-Space>t |
| 452 | \:vert scs find t <C-R>=expand("<cword>")<CR><CR> |
| 453 | nmap <C-Space><C-Space>e |
| 454 | \:vert scs find e <C-R>=expand("<cword>")<CR><CR> |
| 455 | nmap <C-Space><C-Space>i |
| 456 | \:vert scs find i ^<C-R>=expand("<cfile>")<CR>$<CR> |
| 457 | nmap <C-Space><C-Space>d |
| 458 | \:vert scs find d <C-R>=expand("<cword>")<CR><CR> |
Bram Moolenaar | 802a0d9 | 2016-06-26 16:17:58 +0200 | [diff] [blame] | 459 | nmap <C-Space><C-Space>a |
| 460 | \:vert scs find a <C-R>=expand("<cword>")<CR><CR> |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 461 | |
| 462 | ============================================================================== |
| 463 | 7. Cscope availability and information *cscope-info* |
| 464 | |
| 465 | If you do not already have cscope (it did not come with your compiler |
| 466 | license or OS distribution), then you can download it for free from: |
| 467 | http://cscope.sourceforge.net/ |
| 468 | This is released by SCO under the BSD license. |
| 469 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 470 | In Solaris 2.x, if you have the C compiler license, you will also have |
| 471 | cscope. Both are usually located under /opt/SUNWspro/bin |
| 472 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 473 | There is source to an older version of a cscope clone (called "cs") available |
| 474 | on the net. Due to various reasons, this is not supported with Vim. |
| 475 | |
| 476 | The cscope interface/support for Vim was originally written by |
| 477 | Andy Kahn <ackahn@netapp.com>. The original structure (as well as a tiny |
Bram Moolenaar | 2f05849 | 2017-11-30 20:27:52 +0100 | [diff] [blame] | 478 | bit of code) was adapted from the cscope interface in nvi. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 479 | *cscope-win32* |
Bram Moolenaar | 40962ec | 2018-01-28 22:47:25 +0100 | [diff] [blame] | 480 | For a cscope version for Win32 see (seems abandoned): |
Bram Moolenaar | 2f05849 | 2017-11-30 20:27:52 +0100 | [diff] [blame] | 481 | https://code.google.com/archive/p/cscope-win32/ |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 482 | |
Bram Moolenaar | 402d2fe | 2005-04-15 21:00:38 +0000 | [diff] [blame] | 483 | Win32 support was added by Sergey Khorev <sergey.khorev@gmail.com>. Contact |
Bram Moolenaar | b23c338 | 2005-01-31 19:09:12 +0000 | [diff] [blame] | 484 | him if you have Win32-specific issues. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 485 | |
Bram Moolenaar | 91f84f6 | 2018-07-29 15:07:52 +0200 | [diff] [blame] | 486 | vim:tw=78:ts=8:noet:ft=help:norl: |