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?
Not "vi" as such. vim does that.
There is a script matchit.vim
which can do this:
~/.vim/plugin
directory) by default. See the vim help for matchit-install for details.Once installed, it has to be enabled, e.g., (see matchit.zip : extended % matching for HTML, LaTeX, and many other languages):
filetype plugin on
in your vimrc file.
For further reading:
runtime macros/matchit.vim
rather than the two-part install from the vim wiki.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.