RyanLiu
RyanLiu

Reputation: 1575

yank all lines and paste at the end Vim

Such as title, I want to copy all lines and paste at the end.

BEFORE:

apple
cat
dog
sun

AFTER:

apple apple
cat cat
dog dog
sun sun

Upvotes: 0

Views: 167

Answers (4)

frank.lin
frank.lin

Reputation: 1694

Another way , if your text is like this(~ represents blank)

apple
cat~~
dog~~
sun~~

It means that all word has the same numbers of colomn.

you can ctrl-v to select all and move cursor to the end of "apple" and type p to paste.

Upvotes: 0

romainl
romainl

Reputation: 196546

Another unix-style answer (though I would go with any of @FDinoff's solution):

:%!awk '{print $1, $1}'

And another :normal answer because there's so many ways to enjoy skinning a cat:

:%norm y$A <C-v><C-r>"

And another one:

:%norm y$Pa<space>   <-- just press the <space> bar

Upvotes: 0

FDinoff
FDinoff

Reputation: 31429

Use a substitue command

:%s/.*/& &

Where .* matches everything and & is replaced with the match (in this case the whole line)


Or if you really want to yank the lines you could use a normal command

:%norm yyPJ

Which is run the command yyPJ on every line in normal mode.


Note: These commands will give slightly different output if there is leading whitespace.

Upvotes: 7

kev
kev

Reputation: 161674

If you're on unix-like system:

:%!paste -d' ' % -

Upvotes: 0

Related Questions