There is no way for
vim to know in advance that it's grandparent process (the terminal) is killed so it too, is normally killed as a result of killing the parent processes.
However, on most default setups
vim will create a
.swp file named after the current file being edited; for instance
MyPrecious.java.swp. This file should contain a snapshot of the file
MyPrecious.java just before the
vim process was killed. Unless you have set up
vim to specifically put these
.swp files in some other directory, they should reside in the same directory as the edited file and you can easily restore your editing work.
Note that some of these files starts with a dot
. so they are invisible unless you use
ls -a to list the files in a directory.