Home Explore Blog CI



neovim

19th chunk of `runtime/doc/motion.txt`
ffc365ac0f3658461dbc30c65aebf9cf42f01c92936058f50000000100000c2c
 language).  When not before the end
			of a method, jump to the start or end of the class.
			|exclusive| motion.
						*[m*
[m			Go to [count] previous start of a method (for Java or
			similar structured language).  When not after the
			start of a method, jump to the start or end of the
			class.  When no '{' is found before the cursor this is
			an error. |exclusive| motion.
						*[M*
[M			Go to [count] previous end of a method (for Java or
			similar structured language).  When not after the
			end of a method, jump to the start or end of the
			class.  When no '}' is found before the cursor this is
			an error. |exclusive| motion.

The above two commands assume that the file contains a class with methods.
The class definition is surrounded in '{' and '}'.  Each method in the class
is also surrounded with '{' and '}'.  This applies to the Java language.  The
file looks like this: >

	// comment
	class foo {
		int method_one() {
			body_one();
		}
		int method_two() {
			body_two();
		}
	}

[To try this out copy the text and put it in a new buffer, the help text above
confuses the jump commands]

Starting with the cursor on "body_two()", using "[m" will jump to the '{' at
the start of "method_two()" (obviously this is much more useful when the
method is long!).  Using "2[m" will jump to the start of "method_one()".
Using "3[m" will jump to the start of the class.

						*[#*
[#			Go to [count] previous unmatched "#if" or "#else".
			|exclusive| motion.

						*]#*
]#			Go to [count] next unmatched "#else" or "#endif".
			|exclusive| motion.

These two commands work in C programs that contain #if/#else/#endif
constructs.  It brings you to the start or end of the #if/#else/#endif where
the current line is included.  You can then use "%" to go to the matching line.

						*[star* *[/*
[*  or  [/		Go to [count] previous start of a C comment "/*".
			|exclusive| motion.

						*]star* *]/*
]*  or  ]/		Go to [count] next end of a C comment "*/".
			|exclusive| motion.


						*H*
H			To line [count] from top (Home) of window (default:
			first line on the window) on the first non-blank
			character |linewise|.  See also 'startofline' option.
			Cursor is adjusted for 'scrolloff' option, unless an
			operator is pending, in which case the text may
			scroll.  E.g. "yH" yanks from the first visible line
			until the cursor line (inclusive).

						*M*
M			To Middle line of window, on the first non-blank
			character |linewise|.  See also 'startofline' option.

						*L*
L			To line [count] from bottom of window (default: Last
			line on the window) on the first non-blank character
			|linewise|.  See also 'startofline' option.
			Cursor is adjusted for 'scrolloff' option, unless an
			operator is pending, in which case the text may
			scroll.  E.g. "yL" yanks from the cursor to the last
			visible line.

<LeftMouse>		Moves to the position on the screen where the mouse
			click is |exclusive|.  See also |<LeftMouse>|.  If the
			position is in a status line, that window is made the
			active window and the cursor is not moved.

 vim:tw=78:ts=8:noet:ft=help:norl:

Title: More Vim Motions: Methods, Conditional Compilation, Comments, and Screen Positions
Summary
This section details additional Vim motions, including '[m', '[M', ']m', and ']M' for navigating methods in Java-like code. It explains how to use these commands with counts to jump between method starts, ends, and the class definition. It also covers '[#' and ']'#' for navigating #if/#else/#endif blocks in C code, '[*' and '/*' for moving to the previous start of a C comment, and ']*' and '/*' for moving to the next end of a C comment. Finally, it describes 'H', 'M', and 'L' for moving to the top, middle, and bottom lines of the window, respectively, and how the mouse can be used to position the cursor.