Home Explore Blog CI



neovim

1st chunk of `runtime/doc/pattern.txt`
be6b8bffbe844a44c0e7fde61962ed2ab197cd0357b7d9af0000000100000fa4
*pattern.txt*   Nvim


		  VIM REFERENCE MANUAL    by Bram Moolenaar


Patterns and search commands				*pattern-searches*

The very basics can be found in section |03.9| of the user manual.  A few more
explanations are in chapter 27 |usr_27.txt|.

                                      Type |gO| to see the table of contents.

==============================================================================
1. Search commands				*search-commands*

							*/*
/{pattern}[/]<CR>	Search forward for the [count]'th occurrence of
			{pattern} |exclusive|.

/{pattern}/{offset}<CR>	Search forward for the [count]'th occurrence of
			{pattern} and go |{offset}| lines up or down.
			|linewise|.

							*/<CR>*
/<CR>			Search forward for the [count]'th occurrence of the
			latest used pattern |last-pattern| with latest used
			|{offset}|.

//{offset}<CR>		Search forward for the [count]'th occurrence of the
			latest used pattern |last-pattern| with new
			|{offset}|.  If {offset} is empty no offset is used.

							*?*
?{pattern}[?]<CR>	Search backward for the [count]'th previous
			occurrence of {pattern} |exclusive|.

?{pattern}?{offset}<CR>	Search backward for the [count]'th previous
			occurrence of {pattern} and go |{offset}| lines up or
			down |linewise|.

							*?<CR>*
?<CR>			Search backward for the [count]'th occurrence of the
			latest used pattern |last-pattern| with latest used
			|{offset}|.

??{offset}<CR>		Search backward for the [count]'th occurrence of the
			latest used pattern |last-pattern| with new
			|{offset}|.  If {offset} is empty no offset is used.

							*n*
n			Repeat the latest "/" or "?" [count] times.
			If the cursor doesn't move the search is repeated with
			count + 1.
			|last-pattern|

							*N*
N			Repeat the latest "/" or "?" [count] times in
			opposite direction. |last-pattern|

							*star* *E348* *E349*
*			Search forward for the [count]'th occurrence of the
			word nearest to the cursor.  The word used for the
			search is the first of:
				1. the keyword under the cursor |'iskeyword'|
				2. the first keyword after the cursor, in the
				   current line
				3. the non-blank word under the cursor
				4. the first non-blank word after the cursor,
				   in the current line
			Only whole keywords are searched for, like with the
			command "/\<keyword\>".  |exclusive|
			'ignorecase' is used, 'smartcase' is not.
							*v_star-default*
{Visual}*		In Visual mode, search forward for the current selection.
			|default-mappings|

							*#*
#			Same as "*", but search backward.  The pound sign
			(character 163) also works.  If the "#" key works as
			backspace, try using "stty erase <BS>" before starting
			Vim (<BS> is CTRL-H or a real backspace).
							*v_#-default*
{Visual}#		In Visual mode, search backward for the current selection.
			|default-mappings|

							*gstar*
g*			Like "*", but don't put "\<" and "\>" around the word.
			This makes the search also find matches that are not a
			whole word.

							*g#*
g#			Like "#", but don't put "\<" and "\>" around the word.
			This makes the search also find matches that are not a
			whole word.

							*gd*
gd			Goto local Declaration.  When the cursor is on a local
			variable, this command will jump to its declaration.
			This was made to work for C code, in other languages
			it may not work well.
			First Vim searches for the start of the current
			function, just like "[[".  If it is not found the
			search stops in line 1.  If it is found, Vim goes back
			until a blank line is found.  From this position Vim
			searches for the keyword under the cursor, like with
			"*", but lines that look like a comment are ignored
			(see 'comments' option).
			Note that this is not guaranteed to work, Vim does not
			really check the syntax, it only searches for a match
			with the keyword.  If included files also need to be
			searched use the commands listed in |include-search|.
			After this command |n| searches forward for the next
			match (not backward).

Title: Vim Search Commands
Summary
This section of the Vim reference manual details the various search commands available in Vim, including forward and backward searches with patterns, repeating searches, searching for words under the cursor, and going to local declarations. It describes the syntax and behavior of commands like '/', '?', 'n', 'N', '*', '#', 'g*', 'g#', and 'gd', explaining how they interact with options like 'ignorecase', 'smartcase', and 'iskeyword'.