Home Explore Blog CI



neovim

3rd chunk of `runtime/doc/usr_03.txt`
819ee694d3c9e0661cb4a38a846440617c56305c92e1a9dd0000000100000fa2
 <---------------->
			    %

This also works for [] and {} pairs.  (This can be defined with the
'matchpairs' option.)

When the cursor is not on a useful character, "%" will search forward to find
one.  Thus if the cursor is at the start of the line of the previous example,
"%" will search forward and find the first "(".  Then it moves to its match:

		if (a == (b * c) / d) ~
		---+---------------->
			   %

Other ways to move around code can be found in |usr_29.txt|.

==============================================================================
*03.5*	Moving to a specific line

If you are a C or C++ programmer, you are familiar with error messages such as
the following:

	prog.c:33: j   undeclared (first use in this function) ~

This tells you that you might want to fix something on line 33.  So how do you
find line 33?  One way is to do "9999k" to go to the top of the file and "32j"
to go down thirty-two lines.  It is not a good way, but it works.  A much
better way of doing things is to use the "G" command.  With a count, this
command positions you at the given line number.  For example, "33G" puts you
on line 33.  (For a better way of going through a compiler's error list, see
|usr_30.txt|, for information on the :make command.)
   With no argument, "G" positions you at the end of the file.  A quick way to
go to the start of a file use "gg".  "1G" will do the same, but is a tiny bit
more typing.

	    |	first line of a file   ^
	    |	text text text text    |
	    |	text text text text    |  gg
	7G  |	text text text text    |
	    |	text text text text
	    |	text text text text
	    V	text text text text    |
		text text text text    |  G
		text text text text    |
		last line of a file    V

Another way to move to a line is using the "%" command with a count.  For
example, "50%" moves you halfway through the file, and "90%" goes to near the
end.

The previous assumes that you want to move to a line in the file, no matter if
it's currently visible or not.  What if you want to move to one of the lines
you can see?  This figure shows the three commands you can use:

			+---------------------------+
		H -->	| text sample text	    |
			| sample text		    |
			| text sample text	    |
			| sample text		    |
		M -->	| text sample text	    |
			| sample text		    |
			| text sample text	    |
			| sample text		    |
		L -->	| text sample text	    |
			+---------------------------+

Hints: "H" stands for Home, "M" for Middle and "L" for Last.  Alternatively,
"H" for High, "M" for Middle and "L" for Low.

==============================================================================
*03.6*	Telling where you are

To see where you are in a file, there are three ways:

1.  Use the CTRL-G command.  You get a message like this (assuming the 'ruler'
    option is off):

	"usr_03.txt" line 233 of 650 --35%-- col 45-52 ~

    This shows the name of the file you are editing, the line number where the
    cursor is, the total number of lines, the percentage of the way through
    the file and the column of the cursor.
       Sometimes you will see a split column number.  For example, "col 2-9".
    This indicates that the cursor is positioned on the second character, but
    because character one is a tab, occupying eight spaces worth of columns,
    the screen column is 9.

2.  Set the 'number' option.  This will display a line number in front of
    every line: >

	:set number
<
    To switch this off again: >

	:set nonumber
<
    Since 'number' is a boolean option, prepending "no" to its name has the
    effect of switching it off.  A boolean option has only these two values,
    it is either on or off.
       Vim has many options.  Besides the boolean ones there are options with
    a numerical value and string options.  You will see examples of this where
    they are used.

3.  Set the 'ruler' option.  This will display the cursor position in the
    lower right corner of the Vim window: >

	:set ruler

Using the 'ruler' option has

Title: Vim: Moving to a Specific Line and Checking Cursor Position
Summary
This section details methods for moving to a specific line number in Vim using 'G' command (e.g., '33G' for line 33), 'gg' for the beginning of the file, and 'G' without arguments for the end. It also explains moving by percentage using '%'. It introduces 'H', 'M', and 'L' for moving to the top, middle, and bottom of the visible screen, respectively. Further, the section covers commands like CTRL-G, and options such as 'number' and 'ruler', that display cursor position, line numbers, and other information to enhance navigation and orientation within the file.