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!

  • 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

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



This will copy line 1 through 3.

  • 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

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

:line#,line# co line#


: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).

  • Yes, this does work as a work around to my problem...not doing a yank/put. Thank you – DemiSheep Jul 24 '14 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.