When I left work yesterday I left vim open with the files I was working on. I’m working from home today, so I VPN’ed in, and when I go to edit those same files, I get the warning that there’s another current vim session open with those files.
I know I could just force logout my other user, but that would kill the existing vim session. I think my changes would all be saved in the
Instead, is it possible for me to take that existing vim session and open it with my second login? That way it would for sure preserve all my changes, and I wouldn’t have to open all the same tabs again.
You can kill vim (but don’t use -9) and all your changes will be saved in the
.swp files. Then you start a new vim and use Recover.
How about using
tmux as an alternative? That way you can disconnect your screen session when you are done and then login later (possibly from another machine) and reconnect.
reptyr: Utility for taking an existing running program and attaching it to a new terminal
From the man page: “reptyr is a utility for taking an existing running program and attaching it to a new terminal. Started a long-running process over ssh, but have to leave and don’t want to interrupt it? Just start a screen, use reptyr to grab it, and then kill the ssh session and head on home.”
You are correct that a forced logout / kill of your other vim process will allow you to pickup the “.swp” file left behind and start working with it. Just tested this theory and it worked on Ubuntu anyway. Just make sure you select the “Recover” option when it tells you a swap file already exists.
That should get any modifications that have not been saved, but I’m not sure about other session info like command history.