2

Given a line like this:

<input class="submit" type="submit" value="update general">

What is the best way to jump directly to the value string block?

Usually I’d use ci" to when there is only one string in the line. But in cases with multiple strings, Im looking for a quicker way to jump to the nth " " block.

3 Answers 3

2

Like other text objects, i" takes a count: c2i", but the general expectation is for text objects to expand both ways, so it doesn't really help.

You could count your way to the relevant quote:

5f"

and then do your edit:

ci"

Or you could simply search for up in update:

/up<CR>

and then do your edit:

ci"

FWIW, I am very partial to the "search" method, which is my default navigation method.

Alternatively, you could look around for a plugin that provides exactly what you are looking for, in this case an XML attribute text object. Like this one (untested).

1
  • 1
    I agree. I use search quite a lot too so this is the right solution for me.
    – Vinn
    Dec 4, 2023 at 17:33
1

I would probably type fvf"ci" or fvwwci" (not sure how many ws it takes) because that’s faster for me than counting. Or even $F"ci", but that’s not as general.

1

I would do: 5f"ci"

Where 5f" goes to the fifth quote (star for the third string).

For the nth string it would be: 2*n-1 instead of 5.

1
  • 1
    With (n-1)*2+1 being 2n-1 :-) Even 2n would work, as you can start from the closing quote.
    – Friedrich
    Dec 3, 2023 at 16:21

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.