Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
294 views
in Technique[技术] by (71.8m points)

putty - 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?

question from:https://stackoverflow.com/questions/65713814/yank-text-from-vim-editor-from-one-session-to-another-session

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
  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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...