How to prevent file recovery when the recovered state is identical to the file content?

2

When my PC crashes for some reason and I open my files again in vim, it asks me to perform recovery on previously opened files. The recovery plugin helps a lot, but in 90% of cases the recovered data is identical to the actual file content. Is there a way how to let vim automatically discard the recovery data in such a case and not prompt me about it?

Petr Pudlák

Posted 2013-08-17T13:10:41.537

Reputation: 2 197

1There's no built-in automatic way to do it, but the plugin you refer to has all the pieces you need to do this yourself. The plugin detects and intercepts the swap file warning message; it knows whether the contents have changed (it displays the value of 'modified'); it can delete the swap file (e.g., the :FinishRecovery command). All you have to do is hack the plugin so that on detection of a swap file, if the file was not 'modified', delete the swap file and let you continue uninterrupted. It might be a good idea if it used :echomag to tell you that it did that. – garyjohn – 2013-08-17T19:07:25.810

Answers

4

I'm the author of the Recovery plugin. It should be possible by setting the variable

let g:RecoverPlugin_Edit_Unmodified=1

in your .vimrc.

Christian Brabandt

Posted 2013-08-17T13:10:41.537

Reputation: 1 196