I've got the following code

1 const unrelated = 3;
3 const XYZ = styled.div`
4   display: inline-block;
5   position: absolute;
7   margin: auto;
8 `;
10 const unrelated2 = 6;

With my cursor in line 6, how can I line-select lines 3 to 8?


Doesn't seem to work.

  • 1
    Hi @kadrian and welcome to Vi and Vim! I don't have an easy answer to your question, but vi`V will not work since i` (and a` or i' or i") only work on a single line of code. See :help v_a` for more details. In part, the reason these can't easily work on multiple lines is that you don't have an open and close version of them (as you do with {} or [] or()...) Anyways, this might require some thinking outside the box to figure out.
    – filbranden
    Apr 27, 2020 at 21:57
  • 1
    I see! Thanks for the insight, that makes sense. Hmm, maybe there is room for some kind of "expand select" plugin?
    – kadrian
    Apr 27, 2020 at 22:56

1 Answer 1


The vi` motion from stock Vim will not work, since i` (and a` or i' or i") only work on a single line of code. See :help v_a` for more details.

But it turns out there's a plug-in that helps here, plug-in wellle/targets.vim extends many of the built-in motions and text objects, `i`` included, to make them more powerful.

In particular, it supports multi-line contents inside quotes. As stated in the README file:

Quote Text Objects

These text objects are similar to the built in text objects such as i'. [...]

These quote text objects try to be smarter than the default ones. They count the quotation marks from the beginning of the line to decide which of these are the beginning of a quote and which ones are the end. [...]

Quote text objects work over multiple lines and support seeking. [...]

The targets.vim defines many other very useful text objects, such as function arguments and also using n and l to match the "next" or "last" (previous) text object of that kind (e.g. in' for the next single quoted string, ip' for the previous one.)

  • 1
    Thanks! Installed the plugin and for my example, it's working now. Like you said, since the backticks don't have an opening / closing variant, the plugin also doesn't recognize when you've got nested versions of those, which sounds weird, but I sometimes have those. But it works well enough for the majority of cases. Now I just have to figure out a way to convince the vscode vim plugin maintainers to check this out :D
    – kadrian
    Apr 29, 2020 at 10:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.