chrisbra / Recover.vim

A Plugin to show a diff, whenever recovering a buffer
http://www.vim.org/scripts/script.php?script_id=3068
247 stars 25 forks source link

Handle better the case when same file is opened in two different running Vims #12

Closed y closed 11 years ago

y commented 11 years ago

Most of the time when recover kicks in it's not because of a stale swap file from a dead Vim process, it's when I forget there's a Vim process already open with a file and try to edit the same file in a different Vim process. For those cases it would make sense to not see this:

Swap File found: Diff buffer? 
[Y]es, (N)o, (A)bort: 

and after choosing abort, I'm faced with another choice to abort:

Swap file "file.swp" already exists!

[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:

This is a probably a common case, so it should be made easier by asking a single question, something like:

Already editing the same file in a different process.
Open the file here in read-only mode?
[Y]es, (N)o, (A)bort:
chrisbra commented 11 years ago

On Wed, September 26, 2012 17:56, y wrote:

Most of the time when recover kicks in it's not because of a stale swap file from a dead Vim process, it's when I forget there's a Vim process already open with a file and try to edit the same file in a different Vim process. For those cases it would make sense to not see this:

Swap File found: Diff buffer?
[Y]es, (N)o, (A)bort:

and after choosing abort, I'm faced with another choice to abort:

Swap file "file.swp" already exists!

[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort:

This is a probably a common case, so it should be made easier by asking a single question, something like:

Already editing the same file in a different process.
Open the file here in read-only mode?
[Y]es, (N)o, (A)bort:

That is an interesting question. Unfortunately, there is no support in vimscript to see, whether the file you want to open is already being edited in another vim session. This should possibly be added to vim.

I'll try to create a patch for Vim. Once that is included in Vim, I'll modify Recover.vim accordingly.

regards, Christian

rking commented 11 years ago

:+1: on this.

I could hack together a thing that would work on Linux (and probably other *nices) in the meantime, if you want.

chrisbra commented 11 years ago

Well, if you can hack something together, I'll might include it.

chrisbra commented 11 years ago

Have included a hack for unix Vim. Check commit 8a6859f