*if_cscop.txt*  For Vim version 7.1.  Last change: 2005 Mar 29


		  VIM REFERENCE MANUAL    by Andy Kahn

							*cscope* *Cscope*
This document explains how to use Vim's cscope interface.

Cscope is a tool like ctags, but think of it as ctags on steroids since it
does a lot more than what ctags provides.  In Vim, jumping to a result from
a cscope query is just like jumping to any tag; it is saved on the tag stack
so that with the right keyboard mappings, you can jump back and forth between
functions as you normally would with |tags|.

1. Cscope introduction		|cscope-intro|
2. Cscope related commands	|cscope-commands|
3. Cscope options		|cscope-options|
4. How to use cscope in Vim	|cscope-howtouse|
5. Limitations			|cscope-limitations|
6. Suggested usage		|cscope-suggestions|
7. Availability & Information	|cscope-info|

This is currently for Unix and Win32 only.
{Vi does not have any of these commands}

==============================================================================
1. Cscope introduction					*cscope-intro*

The following text is taken from a version of the cscope man page:

				    -----

  Cscope is an interactive screen-oriented tool that helps you:

       Learn how a C program works without endless flipping through a thick
       listing.

       Locate the section of code to change to fix a bug without having to
       learn the entire program.

       Examine the effect of a proposed change such as adding a value to an
       enum variable.

       Verify that a change has been made in all source files such as adding
       an argument to an existing function.

       Rename a global variable in all source files.

       Change a constant to a preprocessor symbol in selected lines of files.

  It is designed to answer questions like:
       Where is this symbol used?
       Where is it defined?
       Where did this variable get its value?
       What is this global symbol's definition?
       Where is this function in the source files?
       What functions call this function?
       What functions are called by this function?
       Where does the message "out of space" come from?
       Where is this source file in the directory structure?
       What files include this header file?

  Cscope answers these questions from a symbol database that it builds the
  first time it is used on the source files.  On a subsequent call, cscope
  rebuilds the database only if a source file has changed or the list of
  source files is different.  When the database is rebuilt the data for the
  unchanged files is copied from the old database, which makes rebuilding
  much faster than the initial build.

				    -----

When cscope is normally invoked, you will get a full-screen selection
screen allowing you to make a query for one of the above questions.
However, once a match is found to your query and you have entered your
text editor to edit the source file containing match, you cannot simply
jump from tag to tag as you normally would with vi's Ctrl-] or :tag
command.

Vim's cscope interface is done by invoking cscope with its line-oriented
interface, and then parsing the output returned from a query.  The end
result is that cscope query results become just like regular tags, so
you can jump to them just like you do with normal tags (Ctrl-] or :tag)
and then go back by popping off the tagstack with Ctrl-T.  (Please note
however, that you don't actually jump to a cscope tag simply by doing
Ctrl-] or :tag without remapping these commands or setting an option.
See the remaining sections on how the cscope interface works and for
suggested use.)


==============================================================================
2. Cscope related commands				*cscope-commands*

		*:cscope* *:cs* *:scs* *:scscope* *E259* *E262* *E561* *E560*
All cscope commands are accessed through suboptions to the main cscope
command ":cscope".  The shortest abbreviation is ":cs".  The ":scscope"
command does the same and also splits the window (short: "scs").

The available subcommands are:

			*E563* *E564* *E566* *E568* *E569* *E622* *E623*
			*E625* *E626* *E609*
    add   : Add a new cscope database/connection.

	USAGE	:cs add {file|dir} [pre-path] [flags]

	    [pre-path] is the pathname used with the -P command to cscope.

	    [flags] are any additional flags you want to pass to cscope.

	EXAMPLES >
	    :cscope add /usr/local/cdb/cscope.out
	    :cscope add /projects/vim/cscope.out /usr/local/vim
	    :cscope add cscope.out /usr/local/vim -C
<
				      *cscope-find* *cs-find*
						*E565* *E567*
    find  : Query cscope.  All cscope query options are available
	    except option #5 ("Change this grep pattern").

	USAGE	:cs find {querytype} {name}

	    {querytype} corresponds to the actual cscope line
	    interface numbers as well as default nvi commands:

		0 or s: Find this C symbol
		1 or g: Find this definition
		2 or d: Find functions called by this function
		3 or c: Find functions calling this function
		4 or t: Find this text string
		6 or e: Find this egrep pattern
		7 or f: Find this file
		8 or i: Find files #including this file

	EXAMPLES >
	    :cscope find c vim_free
	    :cscope find 3 vim_free
<
	    These two examples perform the same query. >

	    :cscope find 0 DEFAULT_TERM
<
	    Executing this example on the source code for Vim 5.1 produces the
	    following output:

	    Cscope tag: DEFAULT_TERM
	       #   line  filename / context / line
	       1   1009  vim-5.1-gtk/src/term.c <<GLOBAL>>
			 #define DEFAULT_TERM (char_u *)"amiga"
	       2   1013  vim-5.1-gtk/src/term.c <<GLOBAL>>
			 #define DEFAULT_TERM (char_u *)"win32"
	       3   1017  vim-5.1-gtk/src/term.c <<GLOBAL>>
			 #define DEFAULT_TERM (char_u *)"pcterm"
	       4   1021  vim-5.1-gtk/src/term.c <<GLOBAL>>
			 #define DEFAULT_TERM (char_u *)"ansi"
	       5   1025  vim-5.1-gtk/src/term.c <<GLOBAL>>
			 #define DEFAULT_TERM (char_u *)"vt52"
	       6   1029  vim-5.1-gtk/src/term.c <<GLOBAL>>
			 #define DEFAULT_TERM (char_u *)"os2ansi"
	       7   1033  vim-5.1-gtk/src/term.c <<GLOBAL>>
			 #define DEFAULT_TERM (char_u *)"ansi"
	       8   1037  vim-5.1-gtk/src/term.c <<GLOBAL>>
			 # undef DEFAULT_TERM
	       9   1038  vim-5.1-gtk/src/term.c <<GLOBAL>>
			 #define DEFAULT_TERM (char_u *)"beos-ansi"
	      10   1042  vim-5.1-gtk/src/term.c <<GLOBAL>>
			 #define DEFAULT_TERM (char_u *)"mac-ansi"
	      11   1335  vim-5.1-gtk/src/term.c <<set_termname>>
			 term = DEFAULT_TERM;
	      12   1459  vim-5.1-gtk/src/term.c <<set_termname>>
			 if (STRCMP(term, DEFAULT_TERM))
	      13   1826  vim-5.1-gtk/src/term.c <<termcapinit>>
			 term = DEFAULT_TERM;
	      14   1833  vim-5.1-gtk/src/term.c <<termcapinit>>
			 term = DEFAULT_TERM;
	      15   3635  vim-5.1-gtk/src/term.c <<update_tcap>>
			 p = find_builtin_term(DEFAULT_TERM);
	    Enter nr of choice (<CR> to abort):

	    The output shows several pieces of information:
	    1. The tag number (there are 15 in this example).
	    2. The line number where the tag occurs.
	    3. The filename where the tag occurs.
	    4. The context of the tag (e.g., global, or the function name).
	    5. The line from the file itself.

    help  : Show a brief synopsis.

	    USAGE   :cs help

						*E260* *E261*
    kill  : Kill a cscope connection (or kill all cscope connections).

	    USAGE   :cs kill {num|partial_name}

	    To kill a cscope connection, the connection number or a partial
	    name must be specified.  The partial name is simply any part of
	    the pathname of the cscope database.  Kill a cscope connection
	    using the partial name with caution!

	    If the specified connection number is -1, then _ALL_ cscope
	    connections will be killed.

    reset : Reinit all cscope connections.

	    USAGE   :cs reset

    show  : Show cscope connections.

	    USAGE   :cs show

							*:lcscope* *:lcs*
This command is same as the ":cscope" command, except when the
'cscopequickfix' option is set, the location list for the current window is
used instead of the quickfix list to show the cscope results.

							*:cstag* *E257* *E562*
If you use cscope as well as ctags, |:cstag| allows you to search one or
the other before making a jump.  For example, you can choose to first
search your cscope database(s) for a match, and if one is not found, then
your tags file(s) will be searched.  The order in which this happens
is determined by the value of |csto|.  See |cscope-options| for more
details.

|:cstag| performs the equivalent of ":cs find g" on the identifier when
searching through the cscope database(s).

|:cstag| performs the equivalent of |:tjump| on the identifier when searching
through your tags file(s).


==============================================================================
3. Cscope options					*cscope-options*

Use the |:set| command to set all cscope options.  Ideally, you would do
this in one of your startup files (e.g., .vimrc).  Some cscope related
variables are only valid within |.vimrc|.  Setting them after vim has
started will have no effect!

							*cscopeprg* *csprg*
'cscopeprg' specifies the command to execute cscope.  The default is
"cscope".  For example: >
	:set csprg=/usr/local/bin/cscope
<
					    *cscopequickfix* *csqf* *E469*
{not available when compiled without the |+quickfix| feature}
'cscopequickfix' specifies whether to use quickfix window to show cscope
results.  This is a list of comma-separated values. Each item consists of
|cscope-find| command (s, g, d, c, t, e, f or i) and flag (+, - or 0).
'+' indicates that results must be appended to quickfix window,
'-' implies previous results clearance, '0' or command absence - don't use
quickfix.  Search is performed from start until first command occurrence.
The default value is "" (don't use quickfix anyway).  The following value
seems to be useful: >
	:set cscopequickfix=s-,c-,d-,i-,t-,e-
<
							*cscopetag* *cst*
If 'cscopetag' set, the commands ":tag" and CTRL-] as well as "vim -t" will
always use |:cstag| instead of the default :tag behavior.  Effectively, by
setting 'cst', you will always search your cscope databases as well as your
tag files.  The default is off.  Examples: >
	:set cst
	:set nocst
<
							*cscopetagorder* *csto*
The value of 'csto' determines the order in which |:cstag| performs a search.
If 'csto' is set to zero, cscope database(s) are searched first, followed
by tag file(s) if cscope did not return any matches.  If 'csto' is set to
one, tag file(s) are searched before cscope database(s).  The default is zero.
Examples: >
	:set csto=0
	:set csto=1
<
						*cscopeverbose* *csverb*
If 'cscopeverbose' is not set (the default), messages will not be printed
indicating success or failure when adding a cscope database.  Ideally, you
should reset this option in your |.vimrc| before adding any cscope databases,
and after adding them, set it.  From then on, when you add more databases
within Vim, you will get a (hopefully) useful message should the database fail
to be added.  Examples: >
	:set csverb
	:set nocsverb
<
						      *cscopepathcomp* *cspc*
The value of 'cspc' determines how many components of a file's path to
display.  With the default value of zero the entire path will be displayed.
The value one will display only the filename with no path.  Other values
display that many components.  For example: >
	:set cspc=3
will display the last 3 components of the file's path, including the file
name itself.

==============================================================================
4. How to use cscope in Vim				*cscope-howtouse*

The first thing you need to do is to build a cscope database for your
source files.  For the most basic case, simply do "cscope -b".  Please
refer to the cscope man page for more details.

Assuming you have a cscope database, you need to "add" the database to Vim.
This establishes a cscope "connection" and makes it available for Vim to use.
You can do this in your .vimrc file, or you can do it manually after starting
vim.  For example, to add the cscope database "cscope.out", you would do:

	:cs add cscope.out

You can double-check the result of this by executing ":cs show".  This will
produce output which looks like this:

 # pid	  database name			      prepend path
 0 28806  cscope.out			      <none>

Note:
Because of the Microsoft RTL limitations, Win32 version shows 0 instead
of the real pid.

Once a cscope connection is established, you can make queries to cscope and
the results will be printed to you.  Queries are made using the command
":cs find".  For example:ll
prod         root                                                                                                                                                                                                                   *howto.txt*	For Vim version 7.1.  Last change: 2006 Apr 02


		  VIM REFERENCE MANUAL	  by Bram Moolenaar


How to ...				*howdoi* *how-do-i* *howto* *how-to*

|tutor|			get started
|:quit|			exit?  I'm trapped, help me!
|initialization|	initialize Vim
|vimrc-intro|		write a Vim script file (vimrc)
|suspend|		suspend Vim
|usr_11.txt|		recover after a crash
|07.4|			keep a backup of my file when writing over it

|usr_07.txt|		edit files
|23.4|			edit binary files
|usr_24.txt|		insert text
|deleting|		delete text
|usr_04.txt|		change text
|04.5|			copy and move text
|usr_25.txt|		format text
|30.6|			format comments
|30.2|			indent C programs
|25.3|			automatically set indent

|usr_26.txt|		repeat commands
|02.5|			undo and redo

|usr_03.txt|		move around
|word-motions|		word motions
|left-right-motions|	left-right motions
|up-down-motions|	up-down motions
|object-motions|	text-object motions
|various-motions|	various motions
|object-select|		text-object selection
|'whichwrap'|		move over line breaks
|'virtualedit'|		move to where there is no text
|usr_27.txt|		specify pattern for searches
|tags-and-searches|	do tags and special searches
|29.4|			search in include'd files used to find
			variables, functions, or macros
|K|			look up manual for the keyword under cursor

|03.7|			scroll
|'sidescroll'|		scroll horizontally/sideways
|'scrolloff'|		set visible context lines

|mode-switching|	change modes
|04.4|			use Visual mode
|'insertmode'|		start Vim in Insert mode

|40.1|			map keys
|24.7|			create abbreviations

|ins-expandtab|		expand a tab to spaces in Insert mode
|i_CTRL-R|		insert contents of a register in Insert mode
|24.3|			complete words in Insert mode
|25.1|			break a line before it gets too long

|20.1|			do command-line editing
|20.3|			do command-line completion
|'cmdheight'|		increase the height of command-line
|10.3|			specify command-line ranges
|40.3|			specify commands to be executed automatically
			before/after reading/writing entering/leaving a
			buffer/window

|'autowrite'|		write automatically
|30.1|			speedup edit-compile-edit cycle or compile and fix
			errors within Vim

|options|		set options
|auto-setting|		set options automatically
|term-dependent-settings| set options depending on terminal name
|save-settings|		save settings
|:quote|		comment my .vim files
|'helpheight'|		change the default help height
|'highlight'|		set various highlighting modes
|'title'|		set the window title
|'icon'|		set window icon title
|'report'|		avoid seeing the change messages on every line
|'shortmess'|		avoid |hit-enter| prompts

|mouse-using|		use mouse with Vim
|usr_08.txt|		manage multiple windows and buffers
|gui.txt|		use the gui

|You can't! (yet)|	do dishes using Vim

|usr_06.txt|		switch on syntax highlighting
|2html.vim|		convert a colored file to HTML
|less|			use Vim like less or more with syntax highlighting

 vim:tw=78:ts=8:ft=help:norl:
                                                                                                                                                                 ./usr/share/vim/vim71/doc/if_cscop.txt                                                              0000644 0000000 0000000 00000045424 11112325261 016460  0                                                                                                    ustar   root                            root                                                                                                                                                                                                                   *if_cscop.txt*  For Vim version 7.1.  Last change: 2005 Mar 29


		  VIM REFERENCE MANUAL    by Andy Kahn

							*cscope* *Cscope*
This document explains how to use Vim's cscope interface.

Cscope is a tool like ctags, but think of it as ctags on steroids since it
does a lot more than what ctags provides.  In Vim, jumping to a result from
a cscope query is just like jumping to any tag; it is saved on the tag stack
so that with the right keyboard mappings, you can jump back and forth between
functions as you normally would with |tags|.

1. Cscope introduction		|cscope-intro|
2. Cscope related commands	|cscope-commands|
3. Cscope options		|cscope-options|
4. How to use cscope in Vim	|cscope-howtouse|
5. Limitations			|cscope-limitations|
6. Suggested usage		|cscope-suggestions|
7. Availability & Information	|cscope-info|

This is currently for Unix and Win32 only.
{Vi does not have any of these commands}

==============================================================================
1. Cscope introduction					*cscope-intro*

The following text is taken from a version of the cscope man page:

				    -----

  Cscope is an interactive screen-oriented tool that helps you:

       Learn how a C program works without endless flipping through a thick
       listing.

       Locate the section of code to change to fix a bug without having to
       learn the entire program.

       Examine the effect of a proposed change such as adding a value to an
       enum variable.

       Verify that a change has been made in all source files such as adding
       an argument to an existing function.

       Rename a global variable in all source files.

       Change a constant to a preprocessor symbol in selected lines of files.

  It is designed to answer questions like:
       Where is this symbol used?
       Where is it defined?
       Where did this variable get its value?
       What is this global symbol's definition?
       Where is this function in the source files?
       What functions call this function?
       What functions are called by this function?
       Where does the message "out of space" come from?
       Where is this source file in the directory structure?
       What files include this header file?

  Cscope answers these questions from a symbol database that it builds the
  first time it is used on the source files.  On a subsequent call, cscope
  rebuilds the database only if a source file has changed or the list of
  source files is different.  When the database is rebuilt the data for the
  unchanged files is copied from the old database, which makes rebuilding
  much faster than the initial build.

				    -----

When cscope is normally invoked, you will get a full-screen selection
screen allowing you to make a query for one of the above questions.
However, once a match