Consider a situation where you seek to find a method, but don’t quite remember the name of the method. Here it would be quite useful to jump from method to method eyeing up the names. Enter ]m
. The motion ]m
jumps forward to the next method or function. Jumping back can be carried out with [m
.
The following method jump options exist:
]m
jump to the beginning of the next method]M
jump to the end of the next method[m
jump to the beginning of the previous method[M
jump to the end of the previous method
In the gif below I demonstrate each of these four options:
Was this useful? Help us improve!
With your feedback, we can improve VimTricks. Click a link to vote:
VimTrick: Jump to next method
Hi Andrew! How does vim knows what is a function? You used Python in your examples, but what if I use Javascript, Go, or something more niche like Scala?
If I understand it correctly, I is derived from the ftype (file mode). In some languages (C, Javascript, etc) where braces are used, it's less precise, where it jumps by block. Not precisely method or function, but once you get the feel for how it works for a particular file type it's certainly still useful.