Author : beriba | 03/10/2013

Vim is very powerful tool. But first you have to discover its secrets. Here is one of them – duplicating one line or many lines using just a keyboard. Yeah, that’s possible and very very useful. You just need to follow few simple steps:
1. Navigate to any place in the line you want to duplicate
2. Press yy
3. Navigate to any other line (or stay in the same line)
4. Press p to paste copied line below the line you’re in or P to paste it above

Quite simple, don’t you think? But what’s when you want to copy more than one line? Copying and pasting it line by line is not a great idea. There’s a command to do that. In step 2 instead of pressing yy you have to press 2Y. In this case the two lines will be copied – the line you’re in and the line below. After pasting, the additional blank line will be added above first copied line. You can copy as many lines as you wish. It could be 6Y, 10Y or 56Y.

Enjoy 🙂