I noticed that if I have a quoted string which contains one new line character I can't use the text objects i" and a" anymore. For example if I have:

This is some text which is less than 80 character and "this is a quoted string
which contains a line break"

When my cursor is on the word string using va" will not work.

This behavior is consistent with what :h aquote says:

Only works within one line.

My questions are:

  • Is there a built-in text object which would have the same behavior as a" but accepting breakline?
  • If not is there a plugin which implement it? (I didn't find a relevant one)
  • If not is there a good reason which makes that is hasn't been implemented?

1 Answer 1


Thinking of a reason why Vim doesn't have this by default ...

At least in VimL and C/C++, to have a string span multiple lines, you can't really have an opening delimiter on a line, and just the ending one on another. "this is a quoted string is an end-of-line comment in vimscript, not an unfinished string. For example, with C, you have to use something like:

printf("first very long line "
       "second line, in code ");

So, briefly put, a multiline string (quote, text lines, quote) is not necessarily a valid multiline string.

I agree it can be useful for other filetypes (text, markdown). Even though, for text, perhaps you'd want to use a typographic quotes solution?

To complement FDinoff's comment/solution of using vim-textobj-quotes: if your filetype has syntax support, and the multiline quoted string appears as a separate syntax item, you can select the whole block using Kana's syntax text object. In the above example, both strings will be selected at once, when using something like viy or vay with cursor inside any of them.

I like the syntax-based approach because it's not limited to multiline strings: I can very well select an entire multiline comment in exactly the same way. And I'm also pretty sure the selection is a valid one.

  • 1
    Thanks for your answer. The justification of the end of line comment is exactly what I was looking for. I'll test the syntax-based approach first because I think it is pretty smart and if I'm not satisfied I'll see how to use FDinoff plugin.
    – statox
    Oct 7, 2015 at 14:48
  • You're welcome; my gain is that it made me give a better look to the typographic quotes plugin (by reedes).
    – VanLaser
    Oct 7, 2015 at 17:37

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.