Consider this situation, which I often follow in python and consider that my cursor is on the letter a of args:

args = ap.add_argument("-i", "--texture", type = str, required=True, help="path of the texture vector")

My objective is to change above line to this:

args = ap.add_argument("-o", "--output", type = str, required=True, help="path of the output")

Now if I have to change all the text objects in this line {"-i", "--texture", "path of the texture vector"). I do this:

ci" [ to change "-i" to "-o"]
ci" [ to change the second text object]
ci" [ then change the last text object]

It is bit clumsy to do 2f" between every ci", what are the more faster and smoother ways of doing this?

  • Do you mean 2; (or simply ;;)?
    – Matt
    Oct 18 '19 at 14:27
  • Yes it is more smooth! Is it possible to have something similar for the ci" ?
    – amitoz
    Oct 18 '19 at 14:41
  • Use "dot"-operator whenever you can. Otherwise, ci" looks short enough.
    – Matt
    Oct 18 '19 at 15:17

It'll be hard to get manually entered keys much shorter than you guys got it in comments. But if you use a mapping you can repeat the "jump to quotes and enter insert" action easily...

nnoremap XX 2f"ci"

(Replace XX with desired key combo.)

Then you just do XX, type in some text, <esc>XX, type in some text, <esc>XX, ... until you've changed all quoted strings in the line.

  • or double it up with imap XX <Esc>XX for an even faster sequence.
    – D. Ben Knoble
    Oct 18 '19 at 21:08

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.