Home Explore Blog CI



neovim

7th chunk of `runtime/doc/usr_29.txt`
ae8c0cf7e82aa6b8a21baa242e7f9475de2eda2173d3af3e0000000100000dc0
 items, like "-I/usr/local/X11".  To add this directory
use: >

	:set path+=/usr/local/X11

When there are many subdirectories, you can use the "*" wildcard.  Example: >

	:set path+=/usr/*/include

This would find files in "/usr/local/include" as well as "/usr/X11/include".

When working on a project with a whole nested tree of included files, the "**"
items is useful.  This will search down in all subdirectories.  Example: >

	:set path+=/projects/invent/**/include

This will find files in the directories:

	/projects/invent/include ~
	/projects/invent/main/include ~
	/projects/invent/main/os/include ~
	etc.

There are even more possibilities.  Check out the 'path' option for info.
   If you want to see which included files are actually found, use this
command: >

	:checkpath!

You will get a (very long) list of included files, the files they include, and
so on.  To shorten the list a bit, Vim shows "(Already listed)" for files that
were found before and doesn't list the included files in there again.


JUMPING TO A MATCH

"[I" produces a list with only one line of text.  When you want to have a
closer look at the first item, you can jump to that line with the command: >

	[<Tab>

You can also use "[ CTRL-I", since CTRL-I is the same as pressing <Tab>.

The list that "[I" produces has a number at the start of each line.  When you
want to jump to another item than the first one, type the number first: >

	3[<Tab>

Will jump to the third item in the list.  Remember that you can use CTRL-O to
jump back to where you started from.


RELATED COMMANDS

	[i		only lists the first match
	]I		only lists items below the cursor
	]i		only lists the first item below the cursor


FINDING DEFINED IDENTIFIERS

The "[I" command finds any identifier.  To find only macros, defined with
"#define" use: >

	[D

Again, this searches in included files.  The 'define' option specifies what a
line looks like that defines the items for "[D".  You could change it to make
it work with other languages than C or C++.
   The commands related to "[D" are:

	[d		only lists the first match
	]D		only lists items below the cursor
	]d		only lists the first item below the cursor

==============================================================================
*29.5*	Finding local identifiers

The "[I" command searches included files.  To search in the current file only,
and jump to the first place where the word under the cursor is used: >

	gD

Hint: Goto Definition.  This command is very useful to find a variable or
function that was declared locally ("static", in C terms).  Example (cursor on
"counter"):
>
	   +->   static int counter = 0;
	   |
	   |     int get_counter(void)
	gD |     {
	   |	     ++counter;
	   +--	     return counter;
		 }
<
To restrict the search even further, and look only in the current function,
use this command: >

	gd

This will go back to the start of the current function and find the first
occurrence of the word under the cursor.  Actually, it searches backwards to
an empty line above a "{" in the first column.  From there it searches forward
for the identifier.  Example (cursor on "idx"):
>
		int find_entry(char *name)
		{
	   +->	    int idx;
	   |
	gd |	    for (idx = 0; idx < table_len; ++idx)
	   |		if (strcmp(table[idx].name, name) == 0)
	   +--		    return idx;
		}
<
==============================================================================

Next chapter: |usr_30.txt|  Editing programs

Copyright: see |manual-copyright|  vim:tw=78:ts=8:noet:ft=help:norl:

Title: Jumping to Matches, Finding Defined Identifiers, and Local Identifiers
Summary
This section explains how to jump to specific matches found by '[I' using '[<Tab>' and specifying the line number. It also covers finding macros defined with '#define' using '[D' and its related commands. The section then details how to find local identifiers within the current file using 'gD' to find a variable or function declared locally, and 'gd' to find the first occurrence of the word under the cursor within the current function.