If I have something selected in Vim in visual mode, how can I duplicate that selection and place it below or above the selection?
Press v to begin character-based visual selection, or V to select whole lines, or Ctrl-v or Ctrl-q to select a block. Move the cursor to the end of the text to be cut/copied. While selecting text, you can perform searches and other advanced movement. Press d (delete) to cut, or y (yank) to copy.
For copy: Place cursor on starting of block and press md and then goto end of block and press y'd. This will select the block to paste it press p. For cut: Place cursor on starting of block and press ma and then goto end of block and press d'a. This will select the block to paste it press p.
Press y to yank what you've got selected visually, then p to paste below the cursor or P to paste above it.
And since you asked about pasting below the selection block, I'll copy what michael said below: After you y to yank, use '> to move it to after the selection block, and then p to paste.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With