6

I am using vi in Solaris 10. I am yanking a range of lines by doing 283,295y, and I do believe the yank command is working as it says 12 lines after I execute the command.

However when I try to copy the lines into the file p or P commands don't actually paste the yanked lines above or below the cursor!

DemiSheep
  • 953
  • Do you press p or write :p? Because pressing p works in my case, writing doesn't. – polym Jul 24 '14 at 18:04
  • Pressing p or P (SHIFT+p) works for individual yank/put (not a range like I need), not :p or :P – DemiSheep Jul 24 '14 at 18:06
  • Let me get this: so you write :283,295y in VI (notice the : ), then press enter, then use arrows to move on the text and then press "P" or "p" and it doesn't work? I just tried it and it works... – Con7e Jul 24 '14 at 20:56
  • : meaning Shift+: -- Could me using Putty to ssh into the machine remotely be part of my problem? – DemiSheep Jul 25 '14 at 19:26
  • Try a different terminal. – Con7e Jul 25 '14 at 20:53

2 Answers2

6

Try using ex commands in vi (according to Solaris User Guide)

:line#,line# co line#

Example:

:283,295 co 512

This command copys line 283 to line 295 and pastes that after line 512 (to activate line numbers in vi use :set nu).

chaos
  • 48,171
3

Well, I just tried this on 2 machines (SUN OS / Linux) and works on both:

In vi (<> represents actions to do / to write):

:<write start line number>,<write end line number>y<press enter>

Then move the cursor with arrow/hjkl keys on where do you want to paste.

Then simply press p or P

Example:

:1,3y

This will copy line 1 through 3.

Con7e
  • 339
  • It's not working for me -- could me using Putty to ssh into the machine remotely be part of my problem? – DemiSheep Jul 25 '14 at 19:28
  • Ok, so now it is working. What is different? I am at home working remotely. So maybe there is something wrong with my docking station / keyboard setup at the office??? – DemiSheep Jul 25 '14 at 19:47
  • Are you using the same program to access the remote station? Could be a computer-specific problem (home vs office). If my answer is correct, please click the "tick" underneath it :) – Con7e Jul 25 '14 at 20:52
  • Yes your answer is the most correct one as per my question about yank/put. I am still having something weird going on as now I can't yank/put again and I'm still working remotely -- I'll figure it out. – DemiSheep Jul 28 '14 at 16:22