-1

I use Putty to connect to a server and I use 2 sessions, because I want to compare 2 .sh files and I find it easier to have both files on different windows.

I am using VIM as a text editor and want to yank a line from the file of the first session to the file of the second session.

I am using V"+y to yank and then p to paste, but it only works if I close the file in the current session and open the other file in the same session.

Is it even possible to yank text from one session and paste it in another?

Petar Yakov
  • 169
  • 2
  • 14
  • 1
    What does `:echo has('clipboard')` in your vim print? – Doj Jan 14 '21 at 06:03
  • That command prints 0. – Petar Yakov Jan 14 '21 at 06:47
  • 1
    Your vim does not support clipboard, `"+` cannot be used for what you want.You may write a mappings to save/load copied text to a file like `~/clipboard.txt`, or try some plugin like [vim-easyclip](https://github.com/svermeulen/vim-easyclip). – Doj Jan 14 '21 at 08:12

2 Answers2

1
  1. You can have two windows in one single Vim "session":

     # two windows stacked vertically
     $ vim -o file1 file2
    
     # two windows stacked horizontally
     $ vim -O file1 file2
    

    And you can even diff them:

     $ vim -d file1 file2
    

    So it seems to me that your initial goal, as described, doesn't warrant the use of two separate Vim "sessions" at all.

    See :help -o, :help -O, :help diff.

  2. To yank between two concurrent Vim "sessions" or one Vim "session" and another program, the bare minimum you need is a clipboard-enabled Vim but it is not clear what you call "session" (is it a Vim session or a shell session?) so I doubt that it will be enough in your case.

romainl
  • 186,200
  • 21
  • 280
  • 313
  • Thanks for the answer. I open different Putty terminals, so I guess it is shell sessions. In general I know about the -o option, but I find it more comfortable when the files are on different windows. I guess I will have to get used to it. – Petar Yakov Jan 15 '21 at 01:56
0

It turned out that I had mouse mode enabled and when I turn it off I can simply Ctrl + C the needed section and add it to the other session. Didn't know the mouse mode makes such a difference.

Petar Yakov
  • 169
  • 2
  • 14