Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Vim: % command doesn't move to first parenthesis

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

  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.

>Solution :

"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!

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading