Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

In the following text block, starting at 1 or 3, and pressing % in normal mode in vim, finds the pair of matching parentheses, and toggles between them if you press % again. Starting at 1 finds the closing ) first. Starting at 3 finds the opening ( first. This is all OK and useful.

Some lines 1 with (stuff 2 in
matching 3 parentheses)

However, starting at 2 and pressing % finds nothing. What's going on?

Update: other commands such as vib can find the (...) block from either 2 or 3 (but not 1) which is one way around the limitation, but still curious...

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

This is actually the documented and expected behavior, from :help %.

Find the next item in this line after or under the cursor and jump to its match.

I do not know of any way to make % search beyond the current line. You could try ]) and its relatives as a workaround.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.