tags:

views:

74

answers:

1

Is it possible to automatically remove the swapfile when the file is saved, and automatically create it again when the file is changed?

And is this a good idea?

EDIT: The reason for wanting to to this is so that I don't have to go through the diff process for files that had no changes after last save if the computer suddenly ran out of power or crashed.

The diff process referred to is; first open the file read only, saving it under a different filename, vimdiffing it and in the end delete it.

It doesn't happen often, but is just as annoying when it does.

+1  A: 

Is it possible to automatically remove the swapfile when the file is saved, and automatically create it again when the file is changed?

And is this a good idea?

Deletion and creation of a file are relatively slow operations. It makes sense to keep the swap file in case if one going to keep editing. Or why else one would keep the VIM running?

Additionally VIM uses the swap file to detect attempts to edit the same file from different VIM instances.

All in all, I think it is a bad idea to try to remove the file.

P.S. Worth noting that when VIM is started in read-only mode as view or vim -R, it doesn't create the swap file. But if once you change the file, the swap file is going to be created.

Dummy00001