I forgot to start screen before I started working, and now I've SSH'd into my machine from my laptop. ps -a gives me the process ID of the vim process. Can I steal the vim session from my other terminal and attach it to my ssh session?

  • 1
    kill it and recover the swap file (vi -r filename) could be ok for you? – Davide Berra Jan 30 '13 at 19:43

The reptyr program would allow you to do that.

| improve this answer | |
  • this thing really works! – sivann Jan 31 '13 at 13:02

You could save the vim session using :mksession ~/session.vim, and reload it in screen using vim -S ~/session.vim.

:mksession essentially saves the current vim session as a file that you can pass around between terminals, or re-open once you have shut your computer down, etc.

| improve this answer | |
  • Actually, if you have the clientserver option built into your executable, you should be able to remotely send the commands that @Pascal mentions to save off the running session and then close it out. You could then restore it in the term. that you are in. See ':h remote_send()' – pottsdl Jan 31 '13 at 15:33
  • This works without the need to install another program. Great solution – Kyle Kochis Apr 18 '16 at 19:12

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.