How to paste from buffer in ex mode of vim?
I understand that you want to:
- yank the current line and the two lines below in the current buffer,
- open an empty buffer in a new horizontal split and
- paste those three lines in the empty buffer.
Is that correct?
What I don't get is why you would want to do it from Ex mode while it's so easy (and working) in normal mode:
3yy
:new<cr>
p
I think that you are confusing ex mode, accessible with Q
and command mode, accessible with :
. You probably also confuse the :p[rint]
command and the :pu[t]
command.
Do the following from normal mode:
:.,+2y|new|put!
It may be helpful to know that you can also directly write those three lines to a file with:
:.,+2w filename
You can use one of the following to copy from the clipboard in Vim:
"+p
"*p
SHIFTINSERT
Which one you use depends on your environment.
If you're using gVim or MacVim, you'll want "+p
If you're using Vim from the command line, you'll want "*p
If you're in insert mode or ex mode (I think) you use SHIFTINSERT
By insert I mean the key over by HOME, PAGE UP, and DELETE
Explanation:
"
means you're going to specify a register- there are 26 custom registers - 1 for each letter
- there are many other registers (see this)
+
or"
refers to the unnamed buffer, which represents the system clipboardp
is the normal put command
More info on buffers:
If you want, you can store different text in different buffers.
To yank 3 lines to the buffer named x use this:
"x3yy
To paste the contents of the buffer named y above the cursor:
"yP