Note that there are some explanatory texts on larger screens.

plurals
  1. POvim: How do I replace a character under my cursor with previously yanked text (more than once)?
    primarykey
    data
    text
    <p>Let's say I've yanked 3 characters "foo" into my clipboard by using a visual select + yank, ie: 'vllly'</p> <p>Then I've moved my cursor to another character (let's call this character x) on line 5 which I'd like to replace with what I yanked previously, namely foo.</p> <p>I can use 'p' to paste foo after x, or 'P' to paste foo before x, but I want to <em>replace</em> x with foo.</p> <p>I can use 'vp' to replace x with foo, but this only works once, as it leaves me with x in my clipboard. In other words, if I move to my next occurrence of x and hit vp again, it doesn't replace it with foo.</p> <p>Sure, I could do a search / replace by using :s/x/foo/gc and then ignoring all occurrences of x that I don't wish to replace, but this is a little tedious to type, particularly when all I need to do is replace 2 or 3 occurrences of x that are very close to my cursor but not on the same line (ie: lines 2, 3 and 7).</p> <p>So currently I'm using :2,7s/x/foo/gc but I wonder if there is a way to move my cursor to x and hit [insert magic button here] to replace it with foo. And then I can move to my next occurrence of x and hit [magic button] again and boom, it's replaced x with foo again.</p> <p>As much as it pains me to use this analogy, imagine you're typing in notepad, and you select 3 characters, hit Ctrl+c to copy them into your clipboard, and then highlight x, and hit Ctrl+v to replace it with foo. Then you highlight another x, and hit Ctrl+v again, and so on.</p> <p>How do I do this in vim?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload