Just like you could jump between pairs, i.e (), can I extend this feature to jump between beginning tags and ending tags?

i.e in bash, jump between if and fi

  • 3
    On my system it does exactly that. I assume the matchit plugin is responsible for that. Usually it's installed by default with every larger vim installation. It is deactivated, though. – Marco Jan 4 '13 at 10:27
  • @Marco Hi, you're right, % does not work for shell scripts unless you have the matchit pluggin installed. Can you convert your comment to an answer and give the url to the matchit pluggin ? – SebMa Sep 10 '17 at 15:44

Here is an example. Suppose you have this code and you press %, the cursor jumps between { and } parens:

enter image description here

matchit.vim extends this functionality, you can do the same with () just move cursor on ( and press %, it jumps between pairs of parenthesis ( )'s, { }'s, [ ]'s. It also jumps between opening and closing tags of C style comments /* and */. And it's smart enough to jump between C preprocessor directives - from #if to #endif and match #elif or #else in between

For more info refer to catonmat.net and vim.org. Note that since vim 6.0, matchit.vim has been included in the standard vim distribution, under the macros/ directory.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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