I know that pressing 'o' in normal or visual mode moves the cursor to a new line and switches the mode to insert.
Therefore, the key sequence would from command mode, A to get into insert mode at end of line, <space> to insert a space, then Ctrl-v to paste. Alternatively, while in insert mode, use the mouse to put the cursor at the end of a line, <space> then Ctrl-v .
Directions: Press the ESC key to be sure you are in vi Command mode. Place the cursor on the line you wish to copy. Type yy to copy the line.
Shortly after :help p
it says:
:[line]pu[t] [x] Put the text [from register x] after [line] (default
current line). This always works |linewise|, thus
this command can be used to put a yanked block as
new lines.
:[line]pu[t]! [x] Put the text [from register x] before [line]
(default current line).
Unfortunately it’s not shorter than your current solution unless you combined it with some keyboard map as suggested in a different answer. For instance, you can map it to any key (even p
):
:nmap p :pu<CR>
Options:
1) Use yy
to yank the whole line (including the end of line character). p
will then paste the line on a new line after the current one and P
(Shift-P) will paste above the current line.
2) Make a mapping: then it's only one or two keys:
:nmap ,p o<ESC>p
:nmap <F4> o<ESC>p
3) The function version of the mapping (unnecessary really, but just for completeness):
:nmap <F4> :call append(line('.'), @")<CR>
" This one may be a little better (strip the ending new-line before pasting)
:nmap <F4> :call append(line('.'), substitute(@", '\n$', '', ''))<CR>
:help let-register
:help :call
:help append()
:help line()
:help nmap
You can paste a buffer in insert mode using <C-R>
followed by the name of the buffer to paste. The default buffer is "
, so you would do
o<C-R>"
I found that I use <C-R>"
very often and bound that to <C-F>
in my vimrc:
inoremap <C-F> <C-R>"
This still uses three keystrokes, but I find it easier than Esc:
o<Alt-p>
Since you're in insert mode after hitting o, the Alt modifier will allow you to use a command as if you weren't.
Using this plugin: https://github.com/tpope/vim-unimpaired
]p
pastes on the line below
[p
pastes on the line above
advantages:
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