Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Automatically delete swap file if no changes #1

Closed
y opened this Issue · 7 comments

2 participants

y chrisbra
y
y commented

I ran across this simple plugin which automatically deletes the swapfile if it contains no differences:
https://github.com/godlygeek/vim-files/blob/master/plugin/SwapExistsDiff.vim

Can you implement similar functionality in your plugin?

chrisbra
Owner

Thanks. I look into it.

regards,
Christian

chrisbra
Owner

Please try the current version.This is an experimental version, but seems to do what you like.

y
y commented

Nice. Further thoughts- when opening the same file from two different vim processes, I would not let the second vim process recover from and delete the swapfile if the first instance is still running. Also would it be possible to allow the user the diff option in addition to the original list of options? I frequently want to abort or quit, especially if the swap file is the result of another running vim instance.

chrisbra
Owner

Yes, that is exactly the problem, why I am unsure about deleting swap files. As far as I know, there is no possibility, to know from within Vim whether a different Vim session is editing the same file. (May be, this feature needs a patch to the Vim source) I need to think about a workaround.
The other options should be possible as well.

y
y commented

The swap file does indicate the process id, so it could be possible to check if that process were still alive and if it was named vim. But i'm not sure if that could be done in a portable way.

chrisbra
Owner

I know. But I think, Vim does not make this information available through its interface. You basically only know, whenever Vim shows its recovery dialog. That's what I mean when I said Vim needs a patch.

chrisbra
Owner

How about, we install an extra autocommand, that checks, whether the swapfile still exists, and if not, recreates the swap file? Would that work until a better approach with Vim can be found?

chrisbra chrisbra closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.