1

In vi, the % key can be used to jump to a matching opening or closing parenthesis, square bracket or a curly brace.

Could it also be used to jump between matching "do" and "done" in a bash loop?

toliveira
  • 1,533
  • 16
  • 27

1 Answers1

5

Not "vi" as such. vim does that. There is a script matchit.vim which can do this:

For further reading:

The runtime macros/matchit.vim line in ~/.vimrc did not make matchit.vim work in my quick test; the procedure in matchit-install, plus the filetype line did work. As usual, your configuration may differ.

I maintain (and of course use) vi-like-emacs, and wrote comparable functionality for that editor using a different approach (see discussion of "fences" in documentation). In a quick test, I see that matchit.vim does not know about the syntax for case-values in a shell case statement. So there is some room for improvement.

Community
  • 1
  • 1
Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105