I'm looking for a way to move to the next open or closing bracket of a certain type, e.g. {
or }
. Example:
if(true)
{
for(int i = 0; i < 10; i++)
{
SomeFunction();
SomeOtherFuntion();
}
}
Let's say my cursor is on the 'S' in SomeFunction()
and I want to jump to the next }
, i.e. the end bracket of the for loop.
What is an efficient way to do this? The only way I can think of is using /}[ENTER]
, but I'm wondering if there's a simpler way.
Have a look at :help motion.txt
, it contains all the various alternatives.
For {
in the first column, there's ]]
. For unmatched ones, ]}
. In many languages, {
represents the start of a method, then ]m
can be used. But in general, I see no problem with your suggestion of /}<CR>
. If you use that often, you can always define a custom mapping for it:
:noremap ]] /}<CR>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With