Home Explore Blog CI



neovim

7th chunk of `runtime/doc/usr_03.txt`
c5b597a13943d13ac45d814140a4f8d021ac0ce5eddb75ac0000000100000aee
 this power comes at a price, because regular
expressions are a bit tricky to specify.
   In this section we mention only a few essential ones.  More about search
patterns and commands can be found in chapter 27 |usr_27.txt|.  You can find
the full explanation here: |pattern|.


BEGINNING AND END OF A LINE

The ^ character matches the beginning of a line.  On an English-US keyboard
you find it above the 6.  The pattern "include" matches the word include
anywhere on the line.  But the pattern "^include" matches the word include
only if it is at the beginning of a line.
   The $ character matches the end of a line.  Therefore, "was$" matches the
word was only if it is at the end of a line.

Let's mark the places where "/the" matches in this example line with "x"s:

	the solder holding one of the chips melted and the ~
	xxx			  xxx		       xxx

Using "/the$" we find this match:

	the solder holding one of the chips melted and the ~
						       xxx

And with "/^the" we find this one:
	the solder holding one of the chips melted and the ~
	xxx

You can try searching with "/^the$"; it will only match a single line
consisting entirely of "the".  White space does matter here, thus if a line
contains a space after the word, like "the ", the pattern will not match.


MATCHING ANY SINGLE CHARACTER

The . (dot) character matches any existing character.  For example, the
pattern "c.m" matches a string whose first character is a c, whose second
character is anything, and whose third character is m.  Example:

	We use a computer that became the cummin winter. ~
		 xxx		 xxx	  xxx


MATCHING SPECIAL CHARACTERS

If you really want to match a dot, you must avoid its special meaning by
putting a backslash before it.
   If you search for "ter.", you will find these matches:

	We use a computer that became the cummin winter. ~
		      xxxx			    xxxx

Searching for "ter\." only finds the second match.

==============================================================================
*03.10*	Using marks

When you make a jump to a position with the "G" command, Vim remembers the
position from before this jump.  This position is called a mark.  To go back
where you came from, use this command: >

	``

This ` is a backtick or open single-quote character.
   If you use the same command a second time you will jump back again.  That's
because the "`" command is a jump itself, and the position from before this
jump is remembered.

Generally, every time you do a command that can move the cursor further than
within the same line, this is called a jump.  This includes the search
commands "/" and "n" (it doesn't matter how far away the match is).  But not
the character searches with "fx" and "tx" or the word movements "w" and "e".
   Also, "j" and "k" are not considered to be a jump,

Title: Vim: Regular Expressions - Beginning/End of Line, Single Characters, Special Characters, and Marks
Summary
This section introduces basic regular expressions in Vim, focusing on matching the beginning (^) and end ($) of a line. It explains how to match any single character using '.' and how to match special characters like '.' by escaping them with a backslash. The section also discusses Vim marks and how to use the `` command to jump back to the previous cursor position after a jump, defining a 'jump' as any command that moves the cursor beyond the current line, excluding single-line movements like 'fx' and 'tx'.