I'm trying to understand logic of text-object-selection in the presence of double qoutes. In the following lines * denotes cursor position, // denotes my comments.

a"b(c*d)e"f //di) deletes everything inside parens, as expected
a"b(c"*d)e"f //di) deletes everything inside parens, as expected
a"b(c"*d)e"f"g //di) does nothing
a"b"g(c"*d)e"f //di) does nothing

Why in the last two lines doesn't di) work? Why does it depend on the number of quotes outside parentheses? Is there any place where all details are described? (I didn’t find any here.)


It's in the docs, but you need to jump around a bit. :h i) says it's like [(, which in turn is like %, which is affected by 'cpoptions':

When the '%' character is not present in 'cpoptions' |cpo-%|, parens and braces inside double quotes are ignored, unless the number of parens/braces in a line is uneven and this line and the previous one does not end in a backslash. '(', '{', '[', ']', '}' and ')' are also ignored (parens and braces inside single quotes).

That's what you're seeing. If you do :set cpoptions+=%, di) will consistently delete everything inside the parentheses.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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