2

For instance, if the cursor position is right after one of the two commas:

var strains = ["omicron", "delta","alpha"];

the ci" command deletes the content of ", ".

I want this command to only take care of the corresponding " pairs.

2
  • Welcome to Vi and Vim!
    – filbranden
    Dec 12, 2021 at 16:17
  • Title suggest that Vim is doing something wrong but it works as expected: Vim looks for " around your current cursor position. Dec 20, 2021 at 15:40

1 Answer 1

1

You might want to install plug-in wellle/targets.vim.

Among quite a few useful new mappings (you might want to learn about those), it modifies the behavior of i" to recognize pairs of quotes and reliably select the strings inside them.

See this section of the introduction:

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.

1
  • 1
    I wonder if it is that smart to detect if quote is escaped
    – Maxim Kim
    Dec 17, 2021 at 7:15

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.