vim-textobj-quotes
is a Vim plugin providing text objects for the closest
pairs of quotes of any type. Using only iq
or aq
it allows you to operate on
content of single ('), double ("), or back (`) quotes that currently surround
the cursor, are in front of the cursor, or behind (in that order of preference).
In other words, it jumps forward or backwards when needed to reach the quotes.
It's easier to understand by looking at examples (the cursor is shown with |
):
- Before:
foo '1, |2, 3' bar
; after pressingdiq
:foo '|' bar
- Before:
foo| '1, 2, 3' bar
; after pressingdiq
:foo '|' bar
- Before:
foo '1, 2, 3' |bar
; after pressingdiq
:foo '|' bar
- Before:
foo '1, |2, 3' bar
; after pressingdaq
:foo | bar
- Before:
foo| '1, 2, 3' bar
; after pressingdaq
:foo | bar
- Before:
foo '1, 2, 3' |bar
; after pressingdaq
:foo | bar
The examples above are given for single quotes, the plugin works exactly the same way for double (") and back (`) quotes.
At the moment, the plugin has experimental support for multiline and nested quote structures, please report any bugs in the issue tracker.
This plugin requires
vim-textobj-user to be installed. If
you are using Vundle, just add the following lines to your .vimrc
:
Bundle 'kana/vim-textobj-user'
Bundle 'beloglazov/vim-textobj-quotes'
Then run :BundleInstall
to install the plugins.
As most of the time, you need to operate on a text inside quotes, I add the following binding to make it even more convenient to use:
xmap q iq
omap q iq
Now, you just need to press cq
, dq
, yq
, or vq
to operate on the text in
single ('), double ("), or back (`) quotes nearby without manually moving into
them.
Enjoy! :)
Copyright (c) Anton Beloglazov. Distributed under the same terms as Vim itself. See :help license.