Home Explore Blog CI



neovim

1st chunk of `runtime/doc/usr_27.txt`
ab58d7bba94ebedb10a15faf2c6a7d256a29c70d27b85b760000000100000fa7
*usr_27.txt*	Nvim

		     VIM USER MANUAL - by Bram Moolenaar

			 Search commands and patterns


In chapter 3 a few simple search patterns were mentioned |03.9|.  Vim can do
much more complex searches.  This chapter explains the most often used ones.
A detailed specification can be found here: |pattern|

|27.1|	Ignoring case
|27.2|	Wrapping around the file end
|27.3|	Offsets
|27.4|	Matching multiple times
|27.5|	Alternatives
|27.6|	Character ranges
|27.7|	Character classes
|27.8|	Matching a line break
|27.9|	Examples

     Next chapter: |usr_28.txt|  Folding
 Previous chapter: |usr_26.txt|  Repeating
Table of contents: |usr_toc.txt|

==============================================================================
*27.1*	Ignoring case

By default, Vim's searches are case sensitive.  Therefore, "include",
"INCLUDE", and "Include" are three different words and a search will match
only one of them.
   Now switch on the 'ignorecase' option: >

	:set ignorecase

Search for "include" again, and now it will match "Include", "INCLUDE" and
"InClUDe".  (Set the 'hlsearch' option to quickly see where a pattern
matches.)
   You can switch this off again with: >

	:set noignorecase

But let's keep it set, and search for "INCLUDE".  It will match exactly the
same text as "include" did.  Now set the 'smartcase' option: >

	:set ignorecase smartcase

If you have a pattern with at least one uppercase character, the search
becomes case sensitive.  The idea is that you didn't have to type that
uppercase character, so you must have done it because you wanted case to
match.  That's smart!
    With these two options set you find the following matches:

	pattern			matches	~
	word			word, Word, WORD, WoRd, etc.
	Word			Word
	WORD			WORD
	WoRd			WoRd


CASE IN ONE PATTERN

If you want to ignore case for one specific pattern, you can do this by
prepending the "\c" string.  Using "\C" will make the pattern to match case.
This overrules the 'ignorecase' and 'smartcase' options, when "\c" or "\C" is
used their value doesn't matter.

	pattern			matches	~
	\Cword			word
	\CWord			Word
	\cword			word, Word, WORD, WoRd, etc.
	\cWord			word, Word, WORD, WoRd, etc.

A big advantage of using "\c" and "\C" is that it sticks with the pattern.
Thus if you repeat a pattern from the search history, the same will happen, no
matter if 'ignorecase' or 'smartcase' was changed.

	Note:
	The use of "\" items in search patterns depends on the 'magic' option.
	In this chapter we will assume 'magic' is on, because that is the
	standard and recommended setting.  If you would change 'magic', many
	search patterns would suddenly become invalid.

	Note:
	If your search takes much longer than you expected, you can interrupt
	it with CTRL-C on Unix and CTRL-Break on MS-Windows.

==============================================================================
*27.2*	Wrapping around the file end

By default, a forward search starts searching for the given string at the
current cursor location.  It then proceeds to the end of the file.  If it has
not found the string by that time, it starts from the beginning and searches
from the start of the file to the cursor location.
   Keep in mind that when repeating the "n" command to search for the next
match, you eventually get back to the first match.  If you don't notice this
you keep searching forever!  To give you a hint, Vim displays this message:

	search hit BOTTOM, continuing at TOP ~

If you use the "?" command, to search in the other direction, you get this
message:

	search hit TOP, continuing at BOTTOM ~

Still, you don't know when you are back at the first match.  One way to see
this is by switching on the 'ruler' option: >

	:set ruler

Vim will display the cursor position in the lower righthand corner of the
window (in the status line if there is one).  It looks like this:

	101,29       84% ~

The first number is the line number of the cursor.  Remember the line number
where you started, so that you can check if you passed this position

Title: Search Commands and Patterns in Vim: Ignoring Case and Wrapping Around
Summary
This section of the Vim user manual delves into advanced search functionalities, focusing on ignoring case sensitivity using the 'ignorecase' and 'smartcase' options, as well as using "\c" and "\C" within the search pattern itself. Additionally, it covers how Vim handles searches that wrap around the end of the file, providing visual cues and options like 'ruler' to help users track their search progress.