I've been using Spacemacs recently and I am trying to reproduce one nice feature that I've seen there in Vim.

Currently: ci" will change everything inside double quotes (cursor does not have to be inside the quotes) but only on the same line.

Is there is any option or plugin to do it on any line:

<cursor here>some text here

new line "text_to_be_replaced" something

At the moment in Vim it is possible only to go down one line and only then do ci" (even while being outside of quotes). If anyone would know any specific action or plugin that could achieve that I would really appreciate assistance!

Thank you in advance.

  • how about this mapping /"<CR>ci"
    – Sundeep
    Nov 9, 2016 at 2:02
  • Not quite sure what you mean. Is it "find the next quote character and replace inside it, wherever next quote character is"? /"<CR>ci"? You could map that sequence.
    – Amadan
    Nov 9, 2016 at 2:02

1 Answer 1


To define the operator mode mapping, first search for the next double quote. Go into visual mode and then search back. But for an unknown reason I cannot do it with a simple:

onoremap i" /"<cr>vN

However, the following works

function! Test()
 call search('\ze"', "W")
 normal! v
 call search('"\zs', 'Wb')

onoremap i" :<c-u>call Test()<cr>
  • Users of this function should keep in mind: 1) This function only works if the cursor is between two "s. 2) It's not syntax aware. If the cursor is between two separate strings (e.g. "foo"|bar"baz"), it will select the what's between the two closest surrounding quotes (i.e. bar, not foo nor baz).
    – 8bittree
    Nov 9, 2016 at 16:14
  • Yes indeed. @8bittree is perfectly right. We could test the setting with a synIDattr(synID(line('.'), col('.'), what),'name') =~? 'string\|comment\|character' though -- expecting syntax highlighting is activated. Nov 9, 2016 at 16:33

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.