Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim: % command doesn't move to first parenthesis

Tags:

vim

I am reading the vim manual. I am having an unexpected result using the % command.

Here is a quote from the manual:

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)
  ---+---------------->
         %

However, when I repeat the same thing (placing the cursor at the start of the line) and press %, the cursor moves the last ) parenthesis instead.

I didn't configure vim, I am using the default settings. I am wondering if my vim is not configured well. Is there a way to configure vim for it to move the cursor the first parenthesis similar to how it is described in the manual?

I am using gVim on Windows.

like image 215
yankolo Avatar asked Sep 04 '26 18:09

yankolo


1 Answers

"it moves to its match", which means that it will move to the matching paranthesis of the one it found (in this case the closing paranthesis). So it does what it should.

To get back to the first paranthesis you will need to press '%' again!

like image 124
Blondberg Avatar answered Sep 08 '26 13:09

Blondberg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!