代码拉取完成,页面将自动刷新
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>if_cscop - Vim Documentation</title>
<meta name="Generator" content="Vim/8.0">
<meta name="plugin-version" content="vim8.0">
<meta name="syntax" content="help">
<meta name="settings" content="no_pre,use_css,expand_tabs">
<link rel="stylesheet" href="style.css" type="text/css" />
<script src="jquery.min.js" type="text/javascript"></script>
<script src="mark-current-page.js" type="text/javascript"></script>
</head>
<body>
<header>
<div class="header">
<a href="http://vim-jp.org/">vim-jp</a>
/ <a href="http://vim-jp.org/vimdoc-en/">vimdoc-en</a>
/ if_cscop<br />
<a name="top"></a><h1>if_cscop - Vim Documentation</h1>
<a href="index.html">Return to main</a>
<span class="EnglishJapaneseLink">
<span class="CurrentLanguage">English</span>
</span>
</div>
</header>
<nav>
<dl>
<dt>BASIC</dt>
<dd><ul>
<li><a href="quickref.html">quickref</a></li>
<li><a href="sponsor.html">sponsor</a></li>
</ul></dd>
<dt>USER MANUAL</dt>
<dd><ul>
<li><a href="usr_toc.html">usr_toc</a></li>
</ul></dd>
<dt>Getting Started</dt>
<dd><ul>
<li><a href="usr_01.html">usr_01</a></li>
<li><a href="usr_02.html">usr_02</a></li>
<li><a href="usr_03.html">usr_03</a></li>
<li><a href="usr_04.html">usr_04</a></li>
<li><a href="usr_05.html">usr_05</a></li>
<li><a href="usr_06.html">usr_06</a></li>
<li><a href="usr_07.html">usr_07</a></li>
<li><a href="usr_08.html">usr_08</a></li>
<li><a href="usr_09.html">usr_09</a></li>
<li><a href="usr_10.html">usr_10</a></li>
<li><a href="usr_11.html">usr_11</a></li>
<li><a href="usr_12.html">usr_12</a></li>
</ul></dd>
<dt>Editing Effectively</dt>
<dd><ul>
<li><a href="usr_20.html">usr_20</a></li>
<li><a href="usr_21.html">usr_21</a></li>
<li><a href="usr_22.html">usr_22</a></li>
<li><a href="usr_23.html">usr_23</a></li>
<li><a href="usr_24.html">usr_24</a></li>
<li><a href="usr_25.html">usr_25</a></li>
<li><a href="usr_26.html">usr_26</a></li>
<li><a href="usr_27.html">usr_27</a></li>
<li><a href="usr_28.html">usr_28</a></li>
<li><a href="usr_29.html">usr_29</a></li>
<li><a href="usr_30.html">usr_30</a></li>
<li><a href="usr_31.html">usr_31</a></li>
<li><a href="usr_32.html">usr_32</a></li>
</ul></dd>
<dt>Tuning Vim</dt>
<dd><ul>
<li><a href="usr_40.html">usr_40</a></li>
<li><a href="usr_41.html">usr_41</a></li>
<li><a href="usr_42.html">usr_42</a></li>
<li><a href="usr_43.html">usr_43</a></li>
<li><a href="usr_44.html">usr_44</a></li>
<li><a href="usr_45.html">usr_45</a></li>
</ul></dd>
<dt>Making Vim Run</dt>
<dd><ul>
<li><a href="usr_90.html">usr_90</a></li>
</ul></dd>
<dt>General subjects</dt>
<dd><ul>
<li><a href="intro.html">intro</a></li>
<li><a href="index.html">help</a></li>
<li><a href="helphelp.html">helphelp</a></li>
<li><a href="vimindex.html">index</a></li>
<li><a href="tags.html">tags</a></li>
<li><a href="howto.html">howto</a></li>
<li><a href="tips.html">tips</a></li>
<li><a href="message.html">message</a></li>
<li><a href="quotes.html">quotes</a></li>
<li><a href="todo.html">todo</a></li>
<li><a href="debug.html">debug</a></li>
<li><a href="develop.html">develop</a></li>
<li><a href="uganda.html">uganda</a></li>
</ul></dd>
<dt>Basic editing</dt>
<dd><ul>
<li><a href="starting.html">starting</a></li>
<li><a href="editing.html">editing</a></li>
<li><a href="motion.html">motion</a></li>
<li><a href="scroll.html">scroll</a></li>
<li><a href="insert.html">insert</a></li>
<li><a href="change.html">change</a></li>
<li><a href="indent.html">indent</a></li>
<li><a href="undo.html">undo</a></li>
<li><a href="repeat.html">repeat</a></li>
<li><a href="visual.html">visual</a></li>
<li><a href="various.html">various</a></li>
<li><a href="recover.html">recover</a></li>
</ul></dd>
<dt>Advanced editing</dt>
<dd><ul>
<li><a href="cmdline.html">cmdline</a></li>
<li><a href="options.html">options</a></li>
<li><a href="pattern.html">pattern</a></li>
<li><a href="map.html">map</a></li>
<li><a href="tagsrch.html">tagsrch</a></li>
<li><a href="quickfix.html">quickfix</a></li>
<li><a href="windows.html">windows</a></li>
<li><a href="tabpage.html">tabpage</a></li>
<li><a href="syntax.html">syntax</a></li>
<li><a href="spell.html">spell</a></li>
<li><a href="diff.html">diff</a></li>
<li><a href="autocmd.html">autocmd</a></li>
<li><a href="filetype.html">filetype</a></li>
<li><a href="eval.html">eval</a></li>
<li><a href="channel.html">channel</a></li>
<li><a href="fold.html">fold</a></li>
</ul></dd>
<dt>Special issues</dt>
<dd><ul>
<li><a href="print.html">print</a></li>
<li><a href="remote.html">remote</a></li>
<li><a href="term.html">term</a></li>
<li><a href="digraph.html">digraph</a></li>
<li><a href="mbyte.html">mbyte</a></li>
<li><a href="mlang.html">mlang</a></li>
<li><a href="arabic.html">arabic</a></li>
<li><a href="farsi.html">farsi</a></li>
<li><a href="hebrew.html">hebrew</a></li>
<li><a href="russian.html">russian</a></li>
<li><a href="ft_ada.html">ft_ada</a></li>
<li><a href="ft_sql.html">ft_sql</a></li>
<li><a href="hangulin.html">hangulin</a></li>
<li><a href="rileft.html">rileft</a></li>
</ul></dd>
<dt>GUI</dt>
<dd><ul>
<li><a href="gui.html">gui</a></li>
<li><a href="gui_w32.html">gui_w32</a></li>
<li><a href="gui_x11.html">gui_x11</a></li>
</ul></dd>
<dt>Interfaces</dt>
<dd><ul>
<li><a href="if_cscop.html">if_cscop</a></li>
<li><a href="if_lua.html">if_lua</a></li>
<li><a href="if_mzsch.html">if_mzsch</a></li>
<li><a href="if_perl.html">if_perl</a></li>
<li><a href="if_pyth.html">if_pyth</a></li>
<li><a href="if_tcl.html">if_tcl</a></li>
<li><a href="if_ole.html">if_ole</a></li>
<li><a href="if_ruby.html">if_ruby</a></li>
<li><a href="debugger.html">debugger</a></li>
<li><a href="workshop.html">workshop</a></li>
<li><a href="netbeans.html">netbeans</a></li>
<li><a href="sign.html">sign</a></li>
</ul></dd>
<dt>Versions</dt>
<dd><ul>
<li><a href="vi_diff.html">vi_diff</a></li>
<li><a href="version4.html">version4</a></li>
<li><a href="version5.html">version5</a></li>
<li><a href="version6.html">version6</a></li>
<li><a href="version7.html">version7</a></li>
<li><a href="version8.html">version8</a></li>
</ul></dd>
<dt>Remarks about specific systems</dt>
<dd><ul>
<li><a href="os_390.html">os_390</a></li>
<li><a href="os_amiga.html">os_amiga</a></li>
<li><a href="os_beos.html">os_beos</a></li>
<li><a href="os_dos.html">os_dos</a></li>
<li><a href="os_mac.html">os_mac</a></li>
<li><a href="os_mint.html">os_mint</a></li>
<li><a href="os_msdos.html">os_msdos</a></li>
<li><a href="os_os2.html">os_os2</a></li>
<li><a href="os_qnx.html">os_qnx</a></li>
<li><a href="os_risc.html">os_risc</a></li>
<li><a href="os_unix.html">os_unix</a></li>
<li><a href="os_vms.html">os_vms</a></li>
<li><a href="os_win32.html">os_win32</a></li>
</ul></dd>
<dt>Standard plugins</dt>
<dd><ul>
<li><a href="pi_getscript.html">pi_getscript</a></li>
<li><a href="pi_gzip.html">pi_gzip</a></li>
<li><a href="pi_logipat.html">pi_logipat</a></li>
<li><a href="pi_netrw.html">pi_netrw</a></li>
<li><a href="pi_paren.html">pi_paren</a></li>
<li><a href="pi_tar.html">pi_tar</a></li>
<li><a href="pi_vimball.html">pi_vimball</a></li>
<li><a href="pi_zip.html">pi_zip</a></li>
</ul></dd>
<dt>Filetype plugins</dt>
<dd><ul>
<li><a href="pi_spec.html">pi_spec</a></li>
</ul></dd>
<dt>Others</dt>
<dd><ul>
<li><a href="vim_faq.html">vim_faq</a></li>
</ul></dd>
</dl>
</nav>
<article class="Vimdoc VimdocJa">
<div id='vimCodeElement'>
<a class="Constant" href="if_cscop.html" name="if_cscop.txt">if_cscop.txt</a> For <span class="Identifier">Vim version 8.0.</span> Last change: 2017 Jun 14<br>
<br>
<br>
<span class="Identifier">VIM REFERENCE MANUAL by Andy Kahn</span><br>
<br>
<a class="Constant" href="if_cscop.html#cscope" name="cscope">cscope</a> <a class="Constant" href="if_cscop.html#Cscope" name="Cscope">Cscope</a><br>
This document explains how to use Vim's cscope interface.<br>
<br>
Cscope is a tool like ctags, but think of it as ctags on steroids since it<br>
does a lot more than what ctags provides. In Vim, jumping to a result from<br>
a cscope query is just like jumping to any tag; it is saved on the tag stack<br>
so that with the right keyboard mappings, you can jump back and forth between<br>
functions as you normally would with <a class="Identifier" href="tagsrch.html#tags">tags</a>.<br>
<br>
1. Cscope introduction <a class="Identifier" href="if_cscop.html#cscope-intro">cscope-intro</a><br>
2. Cscope related commands <a class="Identifier" href="if_cscop.html#cscope-commands">cscope-commands</a><br>
3. Cscope options <a class="Identifier" href="if_cscop.html#cscope-options">cscope-options</a><br>
4. How to use cscope in Vim <a class="Identifier" href="if_cscop.html#cscope-howtouse">cscope-howtouse</a><br>
5. Limitations <a class="Identifier" href="if_cscop.html#cscope-limitations">cscope-limitations</a><br>
6. Suggested usage <a class="Identifier" href="if_cscop.html#cscope-suggestions">cscope-suggestions</a><br>
7. Availability & Information <a class="Identifier" href="if_cscop.html#cscope-info">cscope-info</a><br>
<br>
This is currently for Unix and Win32 only.<br>
<span class="Special">{Vi does not have any of these commands}</span><br>
<br>
<span class="PreProc">==============================================================================</span><br>
1. Cscope introduction <a class="Constant" href="if_cscop.html#cscope-intro" name="cscope-intro">cscope-intro</a><br>
<br>
The following text is taken from a version of the cscope man page:<br>
<br>
-----<br>
<br>
Cscope is an interactive screen-oriented tool that helps you:<br>
<br>
Learn how a C program works without endless flipping through a thick<br>
listing.<br>
<br>
Locate the section of code to change to fix a bug without having to<br>
learn the entire program.<br>
<br>
Examine the effect of a proposed change such as adding a value to an<br>
enum variable.<br>
<br>
Verify that a change has been made in all source files such as adding<br>
an argument to an existing function.<br>
<br>
Rename a global variable in all source files.<br>
<br>
Change a constant to a preprocessor symbol in selected lines of files.<br>
<br>
It is designed to answer questions like:<br>
Where is this symbol used?<br>
Where is it defined?<br>
Where did this variable get its value?<br>
What is this global symbol's definition?<br>
Where is this function in the source files?<br>
What functions call this function?<br>
What functions are called by this function?<br>
Where does the message "out of space" come from?<br>
Where is this source file in the directory structure?<br>
What files include this header file?<br>
<br>
Cscope answers these questions from a symbol database that it builds the<br>
first time it is used on the source files. On a subsequent call, cscope<br>
rebuilds the database only if a source file has changed or the list of<br>
source files is different. When the database is rebuilt the data for the<br>
unchanged files is copied from the old database, which makes rebuilding<br>
much faster than the initial build.<br>
<br>
-----<br>
<br>
When cscope is normally invoked, you will get a full-screen selection<br>
screen allowing you to make a query for one of the above questions.<br>
However, once a match is found to your query and you have entered your<br>
text editor to edit the source file containing match, you cannot simply<br>
jump from tag to tag as you normally would with vi's Ctrl-] or :tag<br>
command.<br>
<br>
Vim's cscope interface is done by invoking cscope with its line-oriented<br>
interface, and then parsing the output returned from a query. The end<br>
result is that cscope query results become just like regular tags, so<br>
you can jump to them just like you do with normal tags (Ctrl-] or :tag)<br>
and then go back by popping off the tagstack with Ctrl-T. (Please <span class="Todo">note</span><br>
however, that you don't actually jump to a cscope tag simply by doing<br>
Ctrl-] or :tag without remapping these commands or setting an option.<br>
See the remaining sections on how the cscope interface works and for<br>
suggested use.)<br>
<br>
<br>
<span class="PreProc">==============================================================================</span><br>
2. Cscope related commands <a class="Constant" href="if_cscop.html#cscope-commands" name="cscope-commands">cscope-commands</a><br>
<br>
<a class="Constant" href="if_cscop.html#:cscope" name=":cscope">:cscope</a> <a class="Constant" href="if_cscop.html#:cs" name=":cs">:cs</a> <a class="Constant" href="if_cscop.html#:scs" name=":scs">:scs</a> <a class="Constant" href="if_cscop.html#:scscope" name=":scscope">:scscope</a> <a class="Constant" href="if_cscop.html#E259" name="E259">E259</a> <a class="Constant" href="if_cscop.html#E262" name="E262">E262</a> <a class="Constant" href="if_cscop.html#E561" name="E561">E561</a> <a class="Constant" href="if_cscop.html#E560" name="E560">E560</a><br>
All cscope commands are accessed through suboptions to the cscope commands.<br>
<a class="Comment" href="if_cscop.html#:cscope">:cscope</a> or <a class="Comment" href="if_cscop.html#:cs">:cs</a> is the main command<br>
<a class="Comment" href="if_cscop.html#:scscope">:scscope</a> or <a class="Comment" href="if_cscop.html#:scs">:scs</a> does the same and splits the window<br>
<a class="Comment" href="if_cscop.html#:lcscope">:lcscope</a> or <a class="Comment" href="if_cscop.html#:lcs">:lcs</a> uses the location list, see <a class="Identifier" href="if_cscop.html#:lcscope">:lcscope</a><br>
<br>
The available subcommands are:<br>
<br>
<a class="Constant" href="if_cscop.html#E563" name="E563">E563</a> <a class="Constant" href="if_cscop.html#E564" name="E564">E564</a> <a class="Constant" href="if_cscop.html#E566" name="E566">E566</a> <a class="Constant" href="if_cscop.html#E568" name="E568">E568</a> <a class="Constant" href="if_cscop.html#E622" name="E622">E622</a> <a class="Constant" href="if_cscop.html#E623" name="E623">E623</a> <a class="Constant" href="if_cscop.html#E625" name="E625">E625</a><br>
<a class="Constant" href="if_cscop.html#E626" name="E626">E626</a> <a class="Constant" href="if_cscop.html#E609" name="E609">E609</a><br>
add : Add a new cscope database/connection.<br>
<br>
USAGE :cs add {file|dir} <span class="Special">[pre-path]</span> <span class="Special">[flags]</span><br>
<br>
<span class="Special">[pre-path]</span> is the pathname used with the -P command to cscope.<br>
<br>
<span class="Special">[flags]</span> are any additional flags you want to pass to cscope.<br>
<br>
EXAMPLES<br>
<div class="helpExample"> :cscope add /usr/local/cdb/cscope.out<br>
:cscope add /projects/vim/cscope.out /usr/local/vim<br>
:cscope add cscope.out /usr/local/vim -C</div>
<br>
<a class="Constant" href="if_cscop.html#cscope-find" name="cscope-find">cscope-find</a> <a class="Constant" href="if_cscop.html#cs-find" name="cs-find">cs-find</a> <a class="Constant" href="if_cscop.html#E567" name="E567">E567</a><br>
find : Query cscope. All cscope query options are available<br>
except option #5 ("Change this grep pattern").<br>
<br>
USAGE :cs find <span class="Special">{querytype}</span> <span class="Special">{name}</span><br>
<br>
<span class="Special">{querytype}</span> corresponds to the actual cscope line<br>
interface numbers as well as default nvi commands:<br>
<br>
0 or s: Find this C symbol<br>
1 or g: Find this definition<br>
2 or d: Find functions called by this function<br>
3 or c: Find functions calling this function<br>
4 or t: Find this text string<br>
6 or e: Find this egrep pattern<br>
7 or f: Find this file<br>
8 or i: Find files #including this file<br>
9 or a: Find places where this symbol is assigned a value<br>
<br>
For all types, except 4 and 6, leading white space for <span class="Special">{name}</span> is<br>
removed. For 4 and 6 there is exactly one space between <span class="Special">{querytype}</span><br>
and <span class="Special">{name}</span>. Further white space is included in <span class="Special">{name}</span>.<br>
<br>
EXAMPLES<br>
<div class="helpExample"> :cscope find c vim_free<br>
:cscope find 3 vim_free</div>
<br>
These two examples perform the same query: functions calling<br>
"vim_free".<br>
<br>
<div class="helpExample"> :cscope find t initOnce<br>
:cscope find t initOnce</div>
<br>
The first one searches for the text "initOnce", the second one for<br>
" initOnce".<br>
<br>
<div class="helpExample"> :cscope find 0 DEFAULT_TERM</div>
<br>
Executing this example on the source code for Vim 5.1 produces the<br>
following output:<br>
<br>
Cscope tag: DEFAULT_TERM<br>
# line filename / context / line<br>
1 1009 vim-5.1-gtk/src/term.c <<span class="Special"><GLOBAL></span>><br>
#define DEFAULT_TERM (char_u *)"amiga"<br>
2 1013 vim-5.1-gtk/src/term.c <<span class="Special"><GLOBAL></span>><br>
#define DEFAULT_TERM (char_u *)"win32"<br>
3 1017 vim-5.1-gtk/src/term.c <<span class="Special"><GLOBAL></span>><br>
#define DEFAULT_TERM (char_u *)"pcterm"<br>
4 1021 vim-5.1-gtk/src/term.c <<span class="Special"><GLOBAL></span>><br>
#define DEFAULT_TERM (char_u *)"ansi"<br>
5 1025 vim-5.1-gtk/src/term.c <<span class="Special"><GLOBAL></span>><br>
#define DEFAULT_TERM (char_u *)"vt52"<br>
6 1029 vim-5.1-gtk/src/term.c <<span class="Special"><GLOBAL></span>><br>
#define DEFAULT_TERM (char_u *)"os2ansi"<br>
7 1033 vim-5.1-gtk/src/term.c <<span class="Special"><GLOBAL></span>><br>
#define DEFAULT_TERM (char_u *)"ansi"<br>
8 1037 vim-5.1-gtk/src/term.c <<span class="Special"><GLOBAL></span>><br>
# undef DEFAULT_TERM<br>
9 1038 vim-5.1-gtk/src/term.c <<span class="Special"><GLOBAL></span>><br>
#define DEFAULT_TERM (char_u *)"beos-ansi"<br>
10 1042 vim-5.1-gtk/src/term.c <<span class="Special"><GLOBAL></span>><br>
#define DEFAULT_TERM (char_u *)"mac-ansi"<br>
11 1335 vim-5.1-gtk/src/term.c <<span class="Special"><set_termname></span>><br>
term = DEFAULT_TERM;<br>
12 1459 vim-5.1-gtk/src/term.c <<span class="Special"><set_termname></span>><br>
if (STRCMP(term, DEFAULT_TERM))<br>
13 1826 vim-5.1-gtk/src/term.c <<span class="Special"><termcapinit></span>><br>
term = DEFAULT_TERM;<br>
14 1833 vim-5.1-gtk/src/term.c <<span class="Special"><termcapinit></span>><br>
term = DEFAULT_TERM;<br>
15 3635 vim-5.1-gtk/src/term.c <<span class="Special"><update_tcap></span>><br>
p = find_builtin_term(DEFAULT_TERM);<br>
Enter nr of choice (<span class="Special"><CR></span> to abort):<br>
<br>
The output shows several pieces of information:<br>
1. The tag number (there are 15 in this example).<br>
2. The line number where the tag occurs.<br>
3. The filename where the tag occurs.<br>
4. The context of the tag (e.g., global, or the function name).<br>
5. The line from the file itself.<br>
<br>
help : Show a brief synopsis.<br>
<br>
USAGE :cs help<br>
<br>
<a class="Constant" href="if_cscop.html#E261" name="E261">E261</a><br>
kill : Kill a cscope connection (or kill all cscope connections).<br>
<br>
USAGE :cs kill {num|partial_name}<br>
<br>
To kill a cscope connection, the connection number or a partial<br>
name must be specified. The partial name is simply any part of<br>
the pathname of the cscope database. Kill a cscope connection<br>
using the partial name with caution!<br>
<br>
If the specified connection number is -1, then _ALL_ cscope<br>
connections will be killed.<br>
<br>
reset : Reinit all cscope connections.<br>
<br>
USAGE :cs reset<br>
<br>
show : Show cscope connections.<br>
<br>
USAGE :cs show<br>
<br>
<a class="Constant" href="if_cscop.html#:lcscope" name=":lcscope">:lcscope</a> <a class="Constant" href="if_cscop.html#:lcs" name=":lcs">:lcs</a><br>
This command is same as the ":cscope" command, except when the<br>
<a class="Type" href="options.html#'cscopequickfix'">'cscopequickfix'</a> option is set, the location list for the current window is<br>
used instead of the quickfix list to show the cscope results.<br>
<br>
<a class="Constant" href="if_cscop.html#:cstag" name=":cstag">:cstag</a> <a class="Constant" href="if_cscop.html#E257" name="E257">E257</a> <a class="Constant" href="if_cscop.html#E562" name="E562">E562</a><br>
If you use cscope as well as ctags, <a class="Identifier" href="if_cscop.html#:cstag">:cstag</a> allows you to search one or<br>
the other before making a jump. For example, you can choose to first<br>
search your cscope database(s) for a match, and if one is not found, then<br>
your tags file(s) will be searched. The order in which this happens<br>
is determined by the value of <a class="Identifier" href="if_cscop.html#csto">csto</a>. See <a class="Identifier" href="if_cscop.html#cscope-options">cscope-options</a> for more<br>
details.<br>
<br>
<a class="Identifier" href="if_cscop.html#:cstag">:cstag</a> performs the equivalent of ":cs find g" on the identifier when<br>
searching through the cscope database(s).<br>
<br>
<a class="Identifier" href="if_cscop.html#:cstag">:cstag</a> performs the equivalent of <a class="Identifier" href="tagsrch.html#:tjump">:tjump</a> on the identifier when searching<br>
through your tags file(s).<br>
<br>
<br>
<span class="PreProc">==============================================================================</span><br>
3. Cscope options <a class="Constant" href="if_cscop.html#cscope-options" name="cscope-options">cscope-options</a><br>
<br>
Use the <a class="Identifier" href="options.html#:set">:set</a> command to set all cscope options. Ideally, you would do<br>
this in one of your startup files (e.g., .vimrc). Some cscope related<br>
variables are only valid within <a class="Identifier" href="starting.html#.vimrc">.vimrc</a>. Setting them after vim has<br>
started will have no effect!<br>
<br>
<a class="Constant" href="if_cscop.html#cscopeprg" name="cscopeprg">cscopeprg</a> <a class="Constant" href="if_cscop.html#csprg" name="csprg">csprg</a><br>
<a class="Type" href="options.html#'cscopeprg'">'cscopeprg'</a> specifies the command to execute cscope. The default is<br>
"cscope". For example:<br>
<div class="helpExample"> :set csprg=/usr/local/bin/cscope</div>
<br>
<a class="Constant" href="if_cscop.html#cscopequickfix" name="cscopequickfix">cscopequickfix</a> <a class="Constant" href="if_cscop.html#csqf" name="csqf">csqf</a> <a class="Constant" href="if_cscop.html#E469" name="E469">E469</a><br>
<span class="Special">{not available when compiled without the </span><a class="Identifier" href="various.html#+quickfix">+quickfix</a><span class="Special"> feature}</span><br>
<a class="Type" href="options.html#'cscopequickfix'">'cscopequickfix'</a> specifies whether to use quickfix window to show cscope<br>
results. This is a list of comma-separated values. Each item consists of<br>
<a class="Identifier" href="if_cscop.html#cscope-find">cscope-find</a> command (s, g, d, c, t, e, f, i or a) and flag (+, - or 0).<br>
'+' indicates that results must be appended to quickfix window,<br>
'-' implies previous results clearance, '0' or command absence - don't use<br>
quickfix. Search is performed from start until first command occurrence.<br>
The default value is "" (don't use quickfix anyway). The following value<br>
seems to be useful:<br>
<div class="helpExample"> :set cscopequickfix=s-,c-,d-,i-,t-,e-,a-</div>
<br>
<a class="Constant" href="if_cscop.html#cscopetag" name="cscopetag">cscopetag</a> <a class="Constant" href="if_cscop.html#cst" name="cst">cst</a><br>
If <a class="Type" href="options.html#'cscopetag'">'cscopetag'</a> is set, the commands ":tag" and <span class="Special">CTRL-]</span> as well as "vim -t"<br>
will always use <a class="Identifier" href="if_cscop.html#:cstag">:cstag</a> instead of the default :tag behavior. Effectively,<br>
by setting <a class="Type" href="options.html#'cst'">'cst'</a>, you will always search your cscope databases as well as<br>
your tag files. The default is off. Examples:<br>
<div class="helpExample"> :set cst<br>
:set nocst</div>
<br>
<a class="Constant" href="if_cscop.html#cscoperelative" name="cscoperelative">cscoperelative</a> <a class="Constant" href="if_cscop.html#csre" name="csre">csre</a><br>
If <a class="Type" href="options.html#'cscoperelative'">'cscoperelative'</a> is set, then in absence of a prefix given to cscope<br>
(prefix is the argument of -P option of cscope), basename of cscope.out<br>
location (usually the project root directory) will be used as the prefix<br>
to construct an absolute path. The default is off. <span class="Todo">Note</span>: This option is<br>
only effective when cscope (cscopeprg) is initialized without a prefix<br>
path (-P). Examples:<br>
<div class="helpExample"> :set csre<br>
:set nocsre</div>
<br>
<a class="Constant" href="if_cscop.html#cscopetagorder" name="cscopetagorder">cscopetagorder</a> <a class="Constant" href="if_cscop.html#csto" name="csto">csto</a><br>
The value of <a class="Type" href="options.html#'csto'">'csto'</a> determines the order in which <a class="Identifier" href="if_cscop.html#:cstag">:cstag</a> performs a search.<br>
If <a class="Type" href="options.html#'csto'">'csto'</a> is set to zero, cscope database(s) are searched first, followed<br>
by tag file(s) if cscope did not return any matches. If <a class="Type" href="options.html#'csto'">'csto'</a> is set to<br>
one, tag file(s) are searched before cscope database(s). The default is zero.<br>
Examples:<br>
<div class="helpExample"> :set csto=0<br>
:set csto=1</div>
<br>
<a class="Constant" href="if_cscop.html#cscopeverbose" name="cscopeverbose">cscopeverbose</a> <a class="Constant" href="if_cscop.html#csverb" name="csverb">csverb</a><br>
If <a class="Type" href="options.html#'cscopeverbose'">'cscopeverbose'</a> is not set (the default), messages will not be printed<br>
indicating success or failure when adding a cscope database. Ideally, you<br>
should reset this option in your <a class="Identifier" href="starting.html#.vimrc">.vimrc</a> before adding any cscope databases,<br>
and after adding them, set it. From then on, when you add more databases<br>
within Vim, you will get a (hopefully) useful message should the database fail<br>
to be added. Examples:<br>
<div class="helpExample"> :set csverb<br>
:set nocsverb</div>
<br>
<a class="Constant" href="if_cscop.html#cscopepathcomp" name="cscopepathcomp">cscopepathcomp</a> <a class="Constant" href="if_cscop.html#cspc" name="cspc">cspc</a><br>
The value of <a class="Type" href="options.html#'cspc'">'cspc'</a> determines how many components of a file's path to<br>
display. With the default value of zero the entire path will be displayed.<br>
The value one will display only the filename with no path. Other values<br>
display that many components. For example:<br>
<div class="helpExample"> :set cspc=3</div>
will display the last 3 components of the file's path, including the file<br>
name itself.<br>
<br>
<span class="PreProc">==============================================================================</span><br>
4. How to use cscope in Vim <a class="Constant" href="if_cscop.html#cscope-howtouse" name="cscope-howtouse">cscope-howtouse</a><br>
<br>
The first thing you need to do is to build a cscope database for your<br>
source files. For the most basic case, simply do "cscope -b". Please<br>
refer to the cscope man page for more details.<br>
<br>
Assuming you have a cscope database, you need to "add" the database to Vim.<br>
This establishes a cscope "connection" and makes it available for Vim to use.<br>
You can do this in your .vimrc file, or you can do it manually after starting<br>
vim. For example, to add the cscope database "cscope.out", you would do:<br>
<br>
:cs add cscope.out<br>
<br>
You can double-check the result of this by executing ":cs show". This will<br>
produce output which looks like this:<br>
<br>
# pid database name prepend path<br>
0 28806 cscope.out <span class="Special"><none></span><br>
<br>
<span class="Todo">Note</span>:<br>
Because of the Microsoft RTL limitations, Win32 version shows 0 instead<br>
of the real pid.<br>
<br>
Once a cscope connection is established, you can make queries to cscope and<br>
the results will be printed to you. Queries are made using the command<br>
":cs find". For example:<br>
<br>
:cs find g ALIGN_SIZE<br>
<br>
This can get a little cumbersome since one ends up doing a significant<br>
amount of typing. Fortunately, there are ways around this by mapping<br>
shortcut keys. See <a class="Identifier" href="if_cscop.html#cscope-suggestions">cscope-suggestions</a> for suggested usage.<br>
<br>
If the results return only one match, you will automatically be taken to it.<br>
If there is more than one match, you will be given a selection screen to pick<br>
the match you want to go to. After you have jumped to the new location,<br>
simply hit Ctrl-T to get back to the previous one.<br>
<br>
<br>
<span class="PreProc">==============================================================================</span><br>
5. Limitations <a class="Constant" href="if_cscop.html#cscope-limitations" name="cscope-limitations">cscope-limitations</a><br>
<br>
Cscope support for Vim is only available on systems that support these four<br>
system calls: fork(), pipe(), execl(), waitpid(). This means it is mostly<br>
limited to Unix systems.<br>
<br>
Additionally Cscope support works for Win32. For more information and a<br>
cscope version for Win32 see:<br>
<br>
<span class="Constant"><a href="http://iamphet.nm.ru/cscope/index.html">http://iamphet.nm.ru/cscope/index.html</a></span><br>
<br>
The DJGPP-built version from <span class="Constant"><a href="http://cscope.sourceforge.net">http://cscope.sourceforge.net</a></span> is known to not<br>
work with Vim.<br>
<br>
Hard-coded limitation: doing a <a class="Identifier" href="tagsrch.html#:tjump">:tjump</a> when <a class="Identifier" href="if_cscop.html#:cstag">:cstag</a> searches the tag files<br>
is not configurable (e.g., you can't do a tselect instead).<br>
<br>
<span class="PreProc">==============================================================================</span><br>
6. Suggested usage <a class="Constant" href="if_cscop.html#cscope-suggestions" name="cscope-suggestions">cscope-suggestions</a><br>
<br>
Put these entries in your .vimrc (adjust the pathname accordingly to your<br>
setup):<br>
<br>
<div class="helpExample"> if has("cscope")<br>
set csprg=/usr/local/bin/cscope<br>
set csto=0<br>
set cst<br>
set nocsverb<br>
" add any database in current directory<br>
if filereadable("cscope.out")<br>
cs add cscope.out<br>
" else add database pointed to by environment<br>
elseif $CSCOPE_DB != ""<br>
cs add $CSCOPE_DB<br>
endif<br>
set csverb<br>
endif</div>
<br>
By setting <a class="Type" href="options.html#'cscopetag'">'cscopetag'</a>, we have effectively replaced all instances of the :tag<br>
command with :cstag. This includes :tag, Ctrl-], and "vim -t". In doing<br>
this, the regular tag command not only searches your ctags generated tag<br>
files, but your cscope databases as well.<br>
<br>
Some users may want to keep the regular tag behavior and have a different<br>
shortcut to access :cstag. For example, one could map Ctrl-_ (underscore)<br>
to :cstag with the following command:<br>
<br>
<div class="helpExample"> map <C-_> :cstag <C-R>=expand("<cword>")<CR><CR></div>
<br>
A couple of very commonly used cscope queries (using ":cs find") is to<br>
find all functions calling a certain function and to find all occurrences<br>
of a particular C symbol. To do this, you can use these mappings as an<br>
example:<br>
<br>
<div class="helpExample"> map g<C-]> :cs find 3 <C-R>=expand("<cword>")<CR><CR><br>
map g<C-\> :cs find 0 <C-R>=expand("<cword>")<CR><CR></div>
<br>
These mappings for Ctrl-] (right bracket) and Ctrl-\ (backslash) allow you to<br>
place your cursor over the function name or C symbol and quickly query cscope<br>
for any matches.<br>
<br>
Or you may use the following scheme, inspired by Vim/Cscope tutorial from<br>
Cscope Home Page (<span class="Constant"><a href="http://cscope.sourceforge.net/">http://cscope.sourceforge.net/</a></span>):<br>
<br>
<div class="helpExample"> nmap <C-_>s :cs find s <C-R>=expand("<cword>")<CR><CR><br>
nmap <C-_>g :cs find g <C-R>=expand("<cword>")<CR><CR><br>
nmap <C-_>c :cs find c <C-R>=expand("<cword>")<CR><CR><br>
nmap <C-_>t :cs find t <C-R>=expand("<cword>")<CR><CR><br>
nmap <C-_>e :cs find e <C-R>=expand("<cword>")<CR><CR><br>
nmap <C-_>f :cs find f <C-R>=expand("<cfile>")<CR><CR><br>
nmap <C-_>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR><br>
nmap <C-_>d :cs find d <C-R>=expand("<cword>")<CR><CR><br>
nmap <C-_>a :cs find a <C-R>=expand("<cword>")<CR><CR></div>
<br>
<div class="helpExample"> " Using 'CTRL-spacebar' then a search type makes the vim window<br>
" split horizontally, with search result displayed in<br>
" the new window.</div>
<br>
<div class="helpExample"> nmap <C-Space>s :scs find s <C-R>=expand("<cword>")<CR><CR><br>
nmap <C-Space>g :scs find g <C-R>=expand("<cword>")<CR><CR><br>
nmap <C-Space>c :scs find c <C-R>=expand("<cword>")<CR><CR><br>
nmap <C-Space>t :scs find t <C-R>=expand("<cword>")<CR><CR><br>
nmap <C-Space>e :scs find e <C-R>=expand("<cword>")<CR><CR><br>
nmap <C-Space>f :scs find f <C-R>=expand("<cfile>")<CR><CR><br>
nmap <C-Space>i :scs find i ^<C-R>=expand("<cfile>")<CR>$<CR><br>
nmap <C-Space>d :scs find d <C-R>=expand("<cword>")<CR><CR><br>
nmap <C-Space>a :scs find a <C-R>=expand("<cword>")<CR><CR></div>
<br>
<div class="helpExample"> " Hitting CTRL-space *twice* before the search type does a vertical<br>
" split instead of a horizontal one</div>
<br>
<div class="helpExample"> nmap <C-Space><C-Space>s<br>
\:vert scs find s <C-R>=expand("<cword>")<CR><CR><br>
nmap <C-Space><C-Space>g<br>
\:vert scs find g <C-R>=expand("<cword>")<CR><CR><br>
nmap <C-Space><C-Space>c<br>
\:vert scs find c <C-R>=expand("<cword>")<CR><CR><br>
nmap <C-Space><C-Space>t<br>
\:vert scs find t <C-R>=expand("<cword>")<CR><CR><br>
nmap <C-Space><C-Space>e<br>
\:vert scs find e <C-R>=expand("<cword>")<CR><CR><br>
nmap <C-Space><C-Space>i<br>
\:vert scs find i ^<C-R>=expand("<cfile>")<CR>$<CR><br>
nmap <C-Space><C-Space>d<br>
\:vert scs find d <C-R>=expand("<cword>")<CR><CR><br>
nmap <C-Space><C-Space>a<br>
\:vert scs find a <C-R>=expand("<cword>")<CR><CR></div>
<br>
<span class="PreProc">==============================================================================</span><br>
7. Cscope availability and information <a class="Constant" href="if_cscop.html#cscope-info" name="cscope-info">cscope-info</a><br>
<br>
If you do not already have cscope (it did not come with your compiler<br>
license or OS distribution), then you can download it for free from:<br>
<span class="Constant"><a href="http://cscope.sourceforge.net/">http://cscope.sourceforge.net/</a></span><br>
This is released by SCO under the BSD license.<br>
<br>
If you want a newer version of cscope, you will probably have to buy it.<br>
According to the (old) nvi documentation:<br>
<br>
You can buy version 13.3 source with an unrestricted license<br>
for $400 from AT&T Software Solutions by calling +1-800-462-8146.<br>
<br>
Also you can download cscope 13.x and mlcscope 14.x (multi-lingual cscope<br>
which supports C, C++, Java, lex, yacc, breakpoint listing, Ingres, and SDL)<br>
from World-Wide Exptools Open Source packages page:<br>
<span class="Constant"><a href="http://www.bell-labs.com/project/wwexptools/packages.html">http://www.bell-labs.com/project/wwexptools/packages.html</a></span><br>
<br>
In Solaris 2.x, if you have the C compiler license, you will also have<br>
cscope. Both are usually located under /opt/SUNWspro/bin<br>
<br>
SGI developers can also get it. Search for Cscope on this page:<br>
<span class="Constant"><a href="http://freeware.sgi.com/index-by-alpha.html">http://freeware.sgi.com/index-by-alpha.html</a></span><br>
<span class="Constant"><a href="https://toolbox.sgi.com/toolbox/utilities/cscope/">https://toolbox.sgi.com/toolbox/utilities/cscope/</a></span><br>
The second one is for those who have a password for the SGI toolbox.<br>
<br>
There is source to an older version of a cscope clone (called "cs") available<br>
on the net. Due to various reasons, this is not supported with Vim.<br>
<br>
The cscope interface/support for Vim was originally written by<br>
Andy Kahn <ackahn@netapp.com>. The original structure (as well as a tiny<br>
bit of code) was adapted from the cscope interface in nvi. Please report<br>
any problems, suggestions, patches, et al., you have for the usage of<br>
cscope within Vim to him.<br>
<a class="Constant" href="if_cscop.html#cscope-win32" name="cscope-win32">cscope-win32</a><br>
For a cscope version for Win32 see:<br>
<span class="Constant"><a href="http://code.google.com/p/cscope-win32/">http://code.google.com/p/cscope-win32/</a></span><br>
<br>
Win32 support was added by Sergey Khorev <sergey.khorev@gmail.com>. Contact<br>
him if you have Win32-specific issues.<br>
<br>
vim:tw=78:ts=8:ft=help:norl:<br>
</div>
</article>
<footer>
<a href="#top">Return to the top</a> - <a href="index.html">Return to main</a>
<span class="EnglishJapaneseLink">
<span class="CurrentLanguage">English</span>
</span>
<br />
<div style="text-align:right;">
Hosted by <a href="https://github.com/vim-jp/vimdoc-en">vimdoc-en project</a><br />
If you met any problem, please report it to <a href="https://github.com/vim-jp/vimdoc-en/issues">issue</a>.<br />
</div>
</footer>
<!--<script src="js/check-referrer.js" type="text/javascript"></script>-->
</body>
</html>
<!-- vim:set ts=8 sts=2 sw=2 tw=0 et: -->
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。