I'm not sure if I should ask this problem on vim or on Linux/Ubuntu forum. The thing is, I opened multiple termianls on my desktop, and several of them opened various of *.txt files. Not all of them are saved.Then my desktop partially broke down. I can ssh it from my laptop. Is there any way to know which files are opened in vim? And is there any way I can save the unsaved files?
How to show all files opened in vim?
save;linux;crash recovery
If you can modify those files, it's likely that Vim created swap files for them. Swap files have extensions .swp, .swo, ..., etc. You can search for these files using find. Looking in your home directory, for example:find ~ -type f -name '.*.sw?'If the Vim programs are still running, you could expedite the search by looking at which files are opened by the Vim processes. This can be done by examining the process' /proc entry and finding where the fds point to (ls -l /proc/<pid>/fd/).For example:$ pgrep vim | xargs -i ls /proc/{}/fd -ltotal 0lrwx------ 1 muru muru 64 Sep 25 08:31 0 -> /dev/pts/2lrwx------ 1 muru muru 64 Sep 25 08:31 1 -> /dev/pts/2lrwx------ 1 muru muru 64 Sep 25 08:31 2 -> /dev/pts/2lrwx------ 1 muru muru 64 Sep 25 08:31 3 -> socket:[23224440]lrwx------ 1 muru muru 64 Sep 25 08:31 5 -> socket:[23220671]lrwx------ 1 muru muru 64 Sep 25 08:31 7 -> /tmp/.gameoverlayui.log.swptotal 0lrwx------ 1 muru muru 64 Sep 25 08:31 0 -> /dev/pts/5lrwx------ 1 muru muru 64 Sep 25 08:31 1 -> /dev/pts/5lrwx------ 1 muru muru 64 Sep 25 08:31 2 -> /dev/pts/5lrwx------ 1 muru muru 64 Sep 25 08:31 3 -> socket:[23222572]lrwx------ 1 muru muru 64 Sep 25 08:31 5 -> socket:[23223590]lrwx------ 1 muru muru 64 Sep 25 08:31 7 -> /home/muru/.vimhelp.vim.swpSo, I have two Vim windows, each having one file opened.I don't think you can control those processes, not easily1, anyway. You can kill them, and then open those files again. Vim will detect the swap files and offer to recover:$ pkill vim$ vim /tmp/gameoverlayui.logE325: ATTENTIONFound a swap file by the name .gameoverlayui.log.swp          owned by: muru   dated: Fri Sep 25 08:37:49 2015         file name: /tmp/gameoverlayui.log          modified: YES         user name: muru   host name: muru-laptop        process ID: 11066While opening file gameoverlayui.log             dated: Fri Sep 25 08:37:43 2015(1) Another program may be editing the same file.  If this is the case,    be careful not to end up with two different instances of the same    file when making changes.  Quit, or continue with caution.(2) An edit session for this file crashed.    If this is the case, use :recover or vim -r gameoverlayui.log    to recover the changes (see :help recovery).    If you did this already, delete the swap file .gameoverlayui.log.swp    to avoid this message.Swap file .gameoverlayui.log.swp already exists![O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort: 1 You could use reptyr or one of the other solutions described in this Unix & Linux post to reattach the Vim process to your SSH session. I have no idea how that will work.