0

I have opened two vi editors: vi file1 file2. Now file1 opens first, and i want to yank some lines from file1 and put it to file 2 without quitting file1, because more lines can be yanked, so it is just switching between vi's and yanking.

How to achieve it?

RajSanpui
  • 11,556
  • 32
  • 79
  • 146

2 Answers2

2

You can navigate between two multiple open files with :next and :previous (the file has to be saved, it wont allow switching then the current file is "modified").

vstm
  • 12,407
  • 1
  • 51
  • 47
  • Is there any shortened form of `next` and `:previous`? – RajSanpui Aug 05 '11 at 12:45
  • @kingsmasher: exactly `:w`. I dont know if `:wnext` is available in "vi" - just try it. But I share @Jay's sentiment: you should upgrade to vim it makes a lot of things easier. edit: The Short form of next is `:n` eventually you can also use `:prev` (not sure if this is vim-only) – vstm Aug 05 '11 at 12:47
  • 1
    not sure in 'vi' (it's a long time since i used vanilla vi) ... but in vim or gvim since you can 'see' both buffers at the same time you don't need to save to switch focus between them. – Jay Aug 05 '11 at 13:02
  • also, i think 'vi' has the 'b' command to switch buffers, i.e., b 1 or b2 (:b 1 or :b 2 in vim) – Jay Aug 05 '11 at 13:04
0

isn't each file in its own buffer and you can yank the text while buffer 1 is active then switch to buffer 2 and do the put? Btw, stop using vi and switch to vim (you may already be using vim as on some linux distros i'm pretty sure that 'vi' is just a link to 'vim'). In Vim you can actually split the screen and see both buffers at the same time.

Jay
  • 435
  • 3
  • 5
  • " you can yank the text while buffer 1 is active then switch to buffer 2 and do the put?" -> That's what, how to do it? – RajSanpui Aug 05 '11 at 12:42