Petar Yakov
Petar Yakov

Reputation: 179

Yank text from VIM editor from one session to another session

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?

Upvotes: -1

Views: 716

Answers (2)

Petar Yakov
Petar Yakov

Reputation: 179

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.

Upvotes: 0

romainl
romainl

Reputation: 196876

  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.

Upvotes: 1

Related Questions