Jump to matching bracket
If you’re programming in Vim, you probably make judicious use of various brackets: parens, square brackets (braces), curly bracket (curly braces), among others. If you’re writing in lisp, then you’re day-to-day existing is a never ending flood of parentheses. Vim has a simple trick built in to make jumping back and forth between opposing sides of brackets easy: Just press the
Here’s a short screencast showing some Clojure code open, with the cursor easily bouncing back and forth between the open and close
, just by pressing % when on top of either end. This tricks makes finding the matching parenthesis easy.
We’ve heard from a number of you who develop in Ruby and there’s good news: The matchit plugin, which ships with Vim 6.0 and above, extends the
% capability to
do/end blocks as well. Pressing
% on the
do will bounce you do the
end and vice-versa.
Another common trick often paired with the
% command is to remap it to automatically visually select the contents between the matching brackets. You can do that in your
.vimrc like so:
noremap % v%
We are sorry that this post was not useful for you!
Let us improve this post!
Tell us how we can improve this post?