Recently my system become unstable because of a mysterious memory leak. As a result I have the Xorg process frequently killed with Out of memory entry in the /var/log/syslog.
To save my vim session in case of crashes I run it within screen.
Unfortunately, after Xorg is killed I am unable to recovery the vim session. The reattached shell is totally messed. So far every time I was trying to exit vim by issuing :qa command at blind. Then with every press of Enter I get prompt in the same line.
I suspect the vim is not running (have to validate it after next crash) since:
- despite I issued the
:qacommand, newvimsession warns me about presence of the swap file, - I can see the
:qacommand in my.bash_historyfile.
Recovery after close of terminal emulator window works fine.
What (but fixing the memory leak) may I do to preserve my vim session?
Versions: vim - 7.4.52, screen - 4.01.00devel, Ubuntu - 14.04.5
[EDIT] vim is definitively not running after crash - today I found a message ICE default IO error handler doing an exit(), pid = 12810, errno = 11 in the resumed screen window.
1 Answer
If Vim complains about a swap file when opening a file, there are two cases: either it's from another currently running Vim process, or it's from a crashed Vim process.
If it's from a running process, the message will look like so:
E325: ATTENTION Found a swap file by the name ".foo.swp" owned by: muru dated: Thu Feb 16 15:59:59 2017 file name: ~muru/foo modified: no user name: muru host name: localhost process ID: 870 (still running) While opening file "foo" Note how it says (still running) next to the process ID. An error due to a crashed Vim's swap file won't have that (except, if by coincidence, another currently running process got that same PID). If it's from a crashed Vim, you can choose to recover from the swap file, and later delete it.
If it's from a currently running Vim process, you can kill it (the swap file will let you recover) or choose to gracefully exit if you don't want a swap file lying around. For the latter option, if you don't have screen or some such way to interact with the Vim process, you can use Python to send key codes to it, as described in another post by me.