Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Assume I have the text Fnord yanked before and that my cursor resides on the B of the line:


How can I change the text inside () with the previously yanked text?

Currently, I often make the mistake by doing:

  • di( aka "delete inside ()"

yet which leaves me with the exact text again, as the deleted text will be moved to the register.

I want to have:

share|improve this question
Possible duplicate of How to replace a word with a yanked word in normal mode – Rich Jan 20 at 16:52
@Rich The provided question covers the more general case of replacing a yanked word. I think this question is a bit more specific and does not attract the same answers. – k0pernikus Jan 20 at 17:30
Protip: The 0 register will contain the last yanked text. :h quote0 – Peter Rincker Jan 20 at 20:54
The same idea from the mentioned question's accepted answer can be applied here. With the cursor in the parentheses, simply press vi)p. It is the same as in that answer, just with the i) text object instead of the w text object, – EvergreenTree Jan 21 at 2:10
@k0pernikus I'm afraid we'll have to agree to disagree on that one. To me, the important part of both questions is the replacement, and not the text object used to apply it. – Rich Jan 21 at 11:17

You can use visual selection to select the text to replace, and then paste over it as follows:


vi( selects Baz (because it is enclosed in parenthesis), p pastes Fnord over it.

However, this will yank Baz to the register after the paste, which might not be what you want.

share|improve this answer

Unless you specify a register, p (or P) will use the last register that was filled. The unnamed register "" contains the most recently yanked or deleted text (unless another register was specified, e.g. with "ay), but these also go into "0 for yanks or "1 for deletes/changes. See registers.

If the last text was yanked with y you can paste it from the 0 register with "0P. If it was deleted, you could access it with the 2 register with "2P ("1 is now Baz).

Alternatively you could avoid messing with your registers and delete to the blackhole register "_:

share|improve this answer

If installing plugins is an option, you could use yankstack.vim. Then you could retain you current workflow:

Currently, I often make the mistake by doing:

  • di( aka "delete inside ()"
  • Alt+p - cycle to the previous yank
share|improve this answer

Assuming "Fnord" is in register a you can do (with the cursor at the beginning of the line) f(ci(<c-r>a

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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