The command p pastes below the cursor and P pastes above the cursor. What\'s the command to paste in the line where cursor is?
To paste in insert mode you just press Control+R. Then enter the register, e.g. Shift++.
To paste in command mode, you press P, however you've to make sure your line doesn't have a new line character (e.g. yanked by 0v$hy
), otherwise it'll appear above the cursor.
The same for visual mode, see: How to paste a line in a vertical selection block? at Vim SE
This all depends on the type of data in the register you're pasting. If the data is line-oriented data (yanked with yy for instance) it will be pasted as a whole line above or below the cursor. If the data is character-oriented (yanked with e.g. y2w) then it will be pasted at or before the cursor position in the current line.
See :help linewise-register
for more info on the interaction between the type of register and the put command.
Shift + v will select the entire line, but you don't want to do that. Instead, press CTRL + v from the beginning of the line which will select by character, then $ to select to the end of the line. yank y and paste p.
(I know this thread is old, just leaving this and hope this may help someone)
Inspired by @wbg's comment above regarding deleting the line feed, I added these to my mappings:
nnoremap <leader>p :let @"=substitute(@", '\n\+$', '', '')<CR>p
inoremap <leader>p <esc>:let @"=substitute(@", '\n\+$', '', '')<CR>pa
This is useful when I have a file with some SQLs (line by line) and I have to yank into the code.
I'm not sure there is one. I tried to find documentation and ran across the following three documents:
Unfortunately, all three only have the two commands that you list. Particularly, the third link states that The commands to paste are p and P...
I needed to "cast" register contents into a certain (characterwise / linewise / blockwise) mode so often, I wrote the UnconditionalPaste plugin for it. It provides gcp
, glp
, etc. alternatives to the built-in paste commands that force a certain mode (and by now several more variations on this theme, like pasting with joined by commas or queried characters).
With it, you can just use gcp
/ gcP
to paste after / before the cursor position, regardless of how you've yanked the text.