How to cut an entire line in vim and paste it?

vim
VivekVarade123 picture VivekVarade123 · Jan 7, 2012 · Viewed 145.6k times · Source

I know how to use the v command in vim, but I need something which will delete an entire line and it should allow me to paste the same line somewhere else.

Answer

DaedalusFall picture DaedalusFall · Jan 7, 2012

dd in command mode (after pressing escape) will cut the line, p in command mode will paste.

Update:

For a bonus, d and then a movement will cut the equivalent of that movement, so dw will cut a word, d<down-arrow> will cut this line and the line below, d50w will cut 50 words.

yy is copy line, and works like dd.

D cuts from cursor to end of line.

If you've used v (visual mode), you should try V (visual line mode) and <ctrl>v (visual block mode).