If i have something selected in VIM in visual mode .... how can i duplicate that selection and place it below or above the selection.
Do you want to copy/paste the whole line? If so, get out of visual mode, use
yy
to yank the whole line, then
p
to paste.
use y for yank (copy) the selection into a buffer
the p for paste the selection where you want it to be
Just hit 'y' to yank what you've got selected visually, the "p" to paste below the cursor or "P" to paste above.
And since you asked about pasting below the selection block, I'll copy what michael said below: After you y
to yank, you '>
to move to after the selection block, and then p
to paste.
You have two options
- yy which copies current line, then p to paste
- make selection (with v for example), then copy with y and paste with p
In addition to the V...yp combo you might want to know about some jumps '< and '> to get to the last character of the previous visual mode text. Specifically If you want to paste below you'd go V...y'>p if it's a long multiline it may be handy.
It's one of those jumps you may find handy if your doing this a lot