Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Paste as in replace mode

Tags:

vim

I got used to indent my code in such way:

  asd          sthng
  asd someText sthng

I would like to paste something in the space in the first line. I would like to keep indention also.

Result of pasting:

  asd pstdText sthng
  asd someText sthng

Is there a way in VIM to paste a text in a way how replace mode (R) works?

like image 534
Marek Wawrzos Avatar asked Feb 10 '23 18:02

Marek Wawrzos


1 Answers

You can enter replace mode with R and then insert the contents of the register via <C-R>".

Alternatively, if you select the amount of text that corresponds to the to-be-pasted text (or there's a motion that covers such), you can use my UnconditionalPaste plugin to replace the selection with the register (without losing the register contents).

like image 166
Ingo Karkat Avatar answered Mar 02 '23 21:03

Ingo Karkat