Macros to expand/collapse regions
Using text objects can greatly improve your speed by allowing you to handle pieces of text.
In the case of Lisp dialects or HTML, the following macros of text objects can be very handy.
- By pressing
q)
the text inside()
is selected. - Pressing again
q)
will expand the selection to the outer piece of text inside()
and so on. - If you want to go back to an inner selection, just press
q(
The same macros are defined for []
, {}
and <>
nnoremap q) va)
vnoremap q) a)
vnoremap q( <ESC>%f(va)
nnoremap q] va]
vnoremap q] a]
vnoremap q[ <ESC>%f[va]
nnoremap q} va}
vnoremap q} a}
vnoremap q{ <ESC>%f{va}
nnoremap q> va>
vnoremap q> a>
vnoremap q< <ESC>%f<va>
Written by Taurus Olson
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Vim
Authors
Related Tags
#vim
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#