Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Paste multiple times in Vim

This maybe really simple, But I tried searching and I ended up with stuff like copying multiple lines, cut and paste multiple lines etc. What am looking for is pasting a single line multiple times in Vim.

For eg. A line 'X' is copied and I want to paste this line alone for say 30 times, thus I will have 30 'X' lines. Is it possible with a single command in Vim? Please help me.

Note: A single command for paste. Copy of the line can be done by 'y'. for pasting 30 times or so, I need a single command. Please help me here.

like image 652
Lakshmi Narayanan Avatar asked May 22 '13 20:05

Lakshmi Narayanan


People also ask

How do you copy multiple lines?

You can select multiple lines with help of CTRL (or SHIFT for continuous selection) key and do CTRL+C and do CTRL+V in the other spreadsheet.


2 Answers

Yes. Put before the command the number of times you want to repeat the action. And this works with many of vim commands. It would be:

30p 
like image 137
Birei Avatar answered Sep 21 '22 00:09

Birei


In order to copy a line and paste it 30 times, first place the cursor on the line you want to copy, and then:

yy 30p 

This will copy the line and paste it 30 times below it. If you want them in another place, then set the cursor to it, and do the 30p part

like image 36
Mariano Anaya Avatar answered Sep 24 '22 00:09

Mariano Anaya