There are problems with your :vglobal
command and problems with your :y[ank]
.
First, :v
runs against lines that aren't matched by your pattern. You are skipping all lines with at least one character.
Second, :g
and :v
work by running the following command for each line that they match/don't match. That means yank is running multiple times and each time it does it overwrites the register. You need to append to the register. The way you do that is by using the uppercase form of the register name, not the lower case. That also means you can't use non-letter registers like *
.
Third, your yank is not correct. You're trying to yank as if you are in Normal mode. But you're on the command line. You need to use the form :y[ank] [x]
where x
is the name of a register.
So the actual command needs to be something like:
:{range}[gv]/{pattern}/ y [A-Z]
More specifically, based on your use case and assuming register a
...
:10,$g/./ y A
Don't forget to clear register a
before you run this since you're appending.
Update: Since you really want the yanked text to go into the *
register there are two alternatives:
- After the
:g
command runs just do :let @* = @a
.
- Use this
:10,$g/./ yank a | let @* .= @a
The second one runs as a single :g
command; each time a matched line is found it is yanked into register a
and then that is appended to *
using the operator .=
which gives us the equivalent to let @* = @* . @a
. IOW, we don't need A
in this case.
y[ank] [x]
wherex
is the register (if left out yank goes to default reg). Also, yourvglobal
command is skipping every line that has at least one character. That doesn't sound like your intention.:help :v
,:help :yank
:g
or:v
to yank into a register you need to append to the register by using the uppercase letter not the lowercase letter. (I don't think this can be done with*
register).:{range}v/{pattern}/ y X
. If I'm not interpreting your need correctly please update your question with more details.10,$g/./y *
yields the last paragraph into the clipboard and in the "" register.