I am working with two files, and I need to copy a few lines from one file and paste into another file. I know how to copy (yy) and paste (p) in the same file. But that doesn
The below option works most of time and also for pasting later.
"xnyy
x - buffer name
n - number of line to Yank - optional
The lines yanked will be stored in the buffer 'x'.
It can be used anywhere in the edit.
To paste line(s) in the other file,
:e filename&location
Example: Type the below command in the current edit
:e /u/test/Test2.sh
and paste using "xP
P - before cursor
p - after cursor
Complete operation
open file 1 :
vi Test1.sh
a10yy
-Yanked 10 lines
-now open the second file from the current edit
*:e /u/test/Test2.sh*
-move the cursor to the line where you have to paste
*"ap*
--Lines from the buffer '*a*' will be copied after the current cursor pos