Giter Site home page Giter Site logo

chrisbra / recover.vim Goto Github PK

View Code? Open in Web Editor NEW
243.0 6.0 25.0 265 KB

A Plugin to show a diff, whenever recovering a buffer

Home Page: http://www.vim.org/scripts/script.php?script_id=3068

Makefile 2.38% Perl 1.76% Shell 1.29% Python 15.91% Vim Script 78.66%

recover.vim's Introduction

Recover.vim adds a diff option when Vim finds a swap file Say Thanks!

When you open a file in Vim but it was already open in another instance or not closed properly in a past edit, Vim will warn you, but it won't show you what the difference is between the hidden swap file and the regular saved file. Of all the actions you might want to do, the most obvious one is missing: compare, that is, see a diff.

Installation

We recommend installing with a plugin manager (there are several).

Alternatively, download the plugin (either the stable or unstable version), edit it with Vim (vim Recover.vmb), then source it (:so %), and finally restart Vim. You can check successful installation by opening the help file (:h RecoverPlugin).

How to use

Recover.vim adds a new first entry to the list of actions, like this:

Found a swap file by the name "test/normal/.testfile.swp"
        owned by: chrisbra   dated: Wed Nov 28 16:26:42 2012
        file name: ~chrisbra/code/git/vim/Recover/test/normal/testfile
        modified: YES
        user name: chrisbra   host name: R500
        process ID: 4878 [not existing]
While opening file "test/normal/testfile"
            dated: Tue Nov  6 20:11:55 2012
Please choose:
[C]ompare, (O)pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort, (D)elete:

Also, in the case that an active process has the swap file open, Recover.vim adds the relevant process ID to the dialog to make that easier to find.

If you choose the new [C]ompare option, you'll see a vertical split buffer. On the left side, you'll see the file as it is stored on disk. On the right side, you'll see the diff from the recovered swap file.

You can then use the usual Vim merge commands if you want to copy the contents from the swap buffer. When you are finished, you can close the diff version and close the window, by issuing :diffoff! and :close in the window that contains the on-disk version of the file. Be sure to save the recovered version of your file.

To delete the no-longer-needed swap file when in the recovered window, use the command :FinishRecovery. That will delete the swapfile, close the diff window, and end the diff/merge process. Alternatively, you can use the command :RecoverPluginFinish.

The command :RecoverPluginHelp show a small message on what keys can be used to move to the next different region and how to merge the changes from one window into the other.

If your Vim was built with +balloon_eval, Recover.vim will also set up an balloon expression that shows you which buffer contains the recovered version of your file and which buffer contains the unmodified on-disk version of your file, if you move the mouse of the buffer.

If you have setup your statusline, Recover.vim will also inject some info about which buffer contains the on-disk version and which buffer contains the modified, recovered version. Additionally, the read-only buffer will have a filename of something like original file (on disk-version). If you want to save that version, use :saveas.

Get more help via :h RecoverPlugin-manual

How to enable or disable Recover.vim

Once installed, Recover.vim is enabled by default.. To disable it, use :RecoverPluginDisable. To enable it again, use :RecoverPluginEnable.

When enabled, you can also do a one-time skip of the Recover.vim dialog with Ctrl-C. Then, the default Vim dialog (without the [C]ompare option) will be shown.

License & Copyright

The Vim License applies. See :h license © 2009 - 2017 by Christian Brabandt

NO WARRANTY, EXPRESS OR IMPLIED. USE AT-YOUR-OWN-RISK

recover.vim's People

Contributors

anjiro avatar chrisbra avatar coot avatar cshubhamrao avatar elig0n avatar harmth avatar inkarkat avatar kindaro avatar luxigo avatar matjon avatar mendel avatar shanesmith avatar snoblenet avatar sunaku avatar wolftune avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

recover.vim's Issues

no messages shown and file opens

Hey, thank you for creating this immensely useful plugin 😃

I just noticed that the message stopped showing even though I have the file opened in an other vim process.

I tried to isolate the issue, so here's what I've done:

  • for my init.vim: uncommented all other vimplug loading lines of all the other plugins and kept only this one, the issue persists.
    feels like something's happening in the background, but vim stays blank for a little while until the file content appears

  • tested in vim, and couldn't get the "Compare" option to show in the message:
    $ /usr/bin/vim -u testvimrc testfile
    testvimrc:

if empty(glob('~/.vim/autoload/plug.vim'))
  silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  autocmd VimEnter * PlugInstall --sync | source '~/testvimrc'
endif

call plug#begin('~/.vim/plugged')
Plug 'chrisbra/Recover.vim'
call plug#end()

nvim: NVIM v0.4.3
/usr/bin/vim: VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Jan 7 2020 22:53:41) Included patches: 1-100 Compiled by Arch Linux
platform: Linux archiver 5.4.12-arch1-1 #1 SMP PREEMPT Tue, 14 Jan 2020 21:44:31 +0000 x86_64 GNU/Linux

Error detected while processing SwapExists Autocommands for "*"..function recover#ConfirmSwapDiff[22]..<SNR>130_AttentionMessage

Error detected while processing SwapExists Autocommands for "*"..function recover#ConfirmSwapDiff[22]..<SNR>130_AttentionMessage:
line    5:
E484: Can't open file /var/folders/cf/_7_y2ks145l10nznn4_5l1qh0000gn/T/v3pLC4w/1
line   11:
E896: Argument of get() must be a List, Dictionary or Blob
line   12:
E896: Argument of get() must be a List, Dictionary or Blob
Error detected while processing SwapExists Autocommands for "*"..function recover#ConfirmSwapDiff:
line   70:
"dumbpw/engine.py" 99L, 2821B
Press ENTER or type command to continue
$ vim --version
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Apr 06 2022 16:59:21)
macOS version - arm64
Included patches: 1-4700
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl               +file_in_path      +mouse_urxvt       -tag_any_white
+arabic            +find_in_path      +mouse_xterm       -tcl
+autocmd           +float             +multi_byte        +termguicolors
+autochdir         +folding           +multi_lang        +terminal
-autoservername    -footer            -mzscheme          +terminfo
-balloon_eval      +fork()            +netbeans_intg     +termresponse
+balloon_eval_term +gettext           +num64             +textobjects
-browse            -hangul_input      +packages          +textprop
++builtin_terms    +iconv             +path_extra        +timers
+byte_offset       +insert_expand     +perl              +title
+channel           +ipv6              +persistent_undo   -toolbar
+cindent           +job               +popupwin          +user_commands
-clientserver      +jumplist          +postscript        +vartabs
+clipboard         +keymap            +printer           +vertsplit
+cmdline_compl     +lambda            +profile           +vim9script
+cmdline_hist      +langmap           -python            +viminfo
+cmdline_info      +libcall           +python3           +virtualedit
+comments          +linebreak         +quickfix          +visual
+conceal           +lispindent        +reltime           +visualextra
+cryptv            +listcmds          +rightleft         +vreplace
+cscope            +localmap          +ruby              +wildignore
+cursorbind        +lua               +scrollbind        +wildmenu
+cursorshape       +menu              +signs             +windows
+dialog_con        +mksession         +smartindent       +writebackup
+diff              +modify_fname      -sodium            -X11
+digraphs          +mouse             -sound             -xfontset
-dnd               -mouseshape        +spell             -xim
-ebcdic            +mouse_dec         +startuptime       -xpm
+emacs_tags        -mouse_gpm         +statusline        -xsmp
+eval              -mouse_jsbterm     -sun_workshop      -xterm_clipboard
+ex_extra          +mouse_netterm     +syntax            -xterm_save
+extra_search      +mouse_sgr         +tag_binary        
-farsi             -mouse_sysmouse    -tag_old_static    
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/opt/homebrew/share/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H -DMACOS_X -DMACOS_X_DARWIN -g -O2 -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 
Linking: clang -L. -fstack-protector-strong -L/opt/homebrew/lib -L/opt/homebrew/opt/libyaml/lib -L/opt/homebrew/opt/[email protected]/lib -L/opt/homebrew/opt/readline/lib -o vim -lm -lncurses -liconv -lintl -framework AppKit -L/opt/homebrew/opt/lua/lib -llua5.4 -mmacosx-version-min=12.0 -fstack-protector-strong -L/opt/homebrew/Cellar/perl/5.34.0/lib/perl5/5.34.0/darwin-thread-multi-2level/CORE -lperl -L/opt/homebrew/opt/[email protected]/Frameworks/Python.framework/Versions/3.10/lib/python3.10/config-3.10-darwin -lpython3.10 -framework CoreFoundation -lruby.3.1 -L/opt/homebrew/Cellar/ruby/3.1.1/lib 
$

Recover plugin is on 23d1e4766642a55e774deb56fda434c64538b06b via vim-plug

"stat: illegal option -- - dated" on macOS

BSD stat is a very different beast than GNU stat, and BSD stat ships on macOS. My guess is that's somewhere at the root of this error.

I honestly don't know how long this has been going on, since the plugin works fine otherwise and I may not have noticed at all. It's no kind of big deal.

E325: ATTENTION
Found a swap file by the name "extinfo/.cli.py.swp"
            owned by: stat: illegal option -- -  dated: usage: stat [-FLnq] [-f format | -l | -r | -s | -x] [-t timefmt] [file ...]
         file name: ~ryan/src/me/extinfo/extinfo/cli.py
          modified: YES
         user name: ryan  host name: Ryans-MBP
        process ID: 23766
        While opening file "~ryan/src/me/extinfo/extinfo/cli.py"
           dated: Tue Apr  5 16:27:31 2022

splitright/tagbar/feedkeys issues

Hi Christian.

I found 2 new issues and 1 workaround for feedkeys() in CheckRecover(). Here is a patch (i do not know how attach file here), i followed your indentation rules:

--- autoload/recover.vim    2012-04-02 15:24:39.449061803 +0400
+++ autoload/recover.vim.new    2012-04-02 15:24:28.647890097 +0400
@@ -70,7 +70,12 @@
        call recover#DiffRecoveredFile()
        " Not sure, why this needs feedkeys
        " Sometimes cursor is wrong, I hate when this happens
-       call feedkeys(":wincmd p\n:0\n", 't')
+       " Cursor is wrong only when there is a single buffer open, a simple
+       " workaround for this is to check if bufnr('') is 1: in this case
+       " ':wincmd l\n:0\n' must be fed
+       if bufnr('') == 1
+       call feedkeys(":wincmd l\n:0\n", 't')
+       endif
    endif
    let b:did_recovery = 1
     endif
@@ -104,7 +109,10 @@
     let b:mod='recovered version'
     let l:filetype = &ft
     " saved version
+    let curspr = &spr
+    set nospr
     noa vert new
+    let &l:spr = curspr
     0r #
     $d _
     if l:filetype != ""
@@ -116,7 +124,7 @@
     setl noswapfile buftype=nowrite bufhidden=delete nobuflisted
     let b:mod='unmodified version on-disk'
     let swapbufnr=bufnr('')
-    noa wincmd p
+    noa wincmd l
     let b:swapbufnr = swapbufnr
     command! -buffer RecoverPluginFinish :FinishRecovery
     command! -buffer FinishRecovery :call recover#RecoverFinish()
  1. Let's start with second chunk: i just found that Recover do not work for me exactly as expected, because i use 'set splitright' in my .vimrc. The easiest way to fix it - is just to set nospr temporarily just before 'vert' as it is done in the second chunk.
  2. Replacement of 'wincmd p' to 'wincmd l' is due to interference with tagbar (and with taglist as well i believe) which regards 'previous' window on its own and therefore cursor moves inside it. 'wincmd l' works fine as far as buffer to edit is always on the right.
  3. I found that 'wincmd p' (now 'wincmd l') are used second time in CheckRecover() and there is verbose comment on this. I check that this strange cursor behaviour really takes place but only when a buffer to recover is the first open in vim. If i open buffer to recover alongside with already open files then this issue go away: but in this case cursor moves 'correctly' to the window on the right of open buffer, which is wrong. The first chunk just tries to figure out if it is the first buffer in vim or there are others (just testing its bufnr('') against 1) - it works fine for me: now cursor takes correct place in all cases - whether or not the open buffer is the first open buffer in vim or not.

Slow startup

I'm a long time fan of the plugin, thanks for your cotribution.

Lately as startup has become quite slow on my machine.
Any idea on what is going on here?

My nvim version info:

:version
NVIM v0.4.4
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/bin/cc -D_FORTIFY_SOURCE=2 -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -W
strict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURC
E -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/build/neovim/src/build/config -I/build/neovim/src/neovim-0.4.4/src -I/usr/include -I/build/neovim/src/build/src/nvim/auto -I/build/neovim/src/build/incl
ude
Compiled by builduser

Features: +acl +iconv +tui

init.rc file:

call plug#begin()
Plug 'chrisbra/Recover'
call plug#end()

Loging startup times with:

nvim --startup-time logfile

Content of logfile:

times in msec
 clock   self+sourced   self:  sourced script
 clock   elapsed:              other lines

000.005  000.005: --- NVIM STARTING ---
000.238  000.233: locale set
000.428  000.191: inits 1
000.442  000.013: window checked
000.444  000.003: parsing arguments
000.483  000.039: expanding arguments
000.518  000.035: inits 2
000.904  000.387: init highlight
000.958  000.054: waiting for UI
001.723  000.765: done waiting for UI
001.751  000.028: initialized screen early for UI
002.848  001.020  001.020: sourcing /home/jonathf/.config/nvim/autoload/plug.vim
011.616  008.351  008.351: sourcing /usr/share/nvim/runtime/filetype.vim
011.772  000.047  000.047: sourcing /usr/share/nvim/runtime/ftplugin.vim
011.856  000.031  000.031: sourcing /usr/share/nvim/runtime/indent.vim
012.382  000.347  000.347: sourcing /usr/share/nvim/runtime/syntax/syncolor.vim
012.530  000.557  000.210: sourcing /usr/share/nvim/runtime/syntax/synload.vim
012.555  000.641  000.083: sourcing /usr/share/nvim/runtime/syntax/syntax.vim
012.572  010.785  000.695: sourcing /home/jonathf/.config/nvim/init.vim
012.577  000.041: sourcing vimrc file(s)
013.121  000.354  000.354: sourcing /home/jonathf/.config/nvim/plugged/Recover.vim/plugin/recover.vim
013.751  000.375  000.375: sourcing /usr/share/nvim/runtime/plugin/gzip.vim
013.796  000.009  000.009: sourcing /usr/share/nvim/runtime/plugin/health.vim
014.071  000.261  000.261: sourcing /usr/share/nvim/runtime/plugin/man.vim
014.524  000.167  000.167: sourcing /usr/share/nvim/runtime/pack/dist/opt/matchit/plugin/matchit.vim
014.558  000.466  000.298: sourcing /usr/share/nvim/runtime/plugin/matchit.vim
014.685  000.113  000.113: sourcing /usr/share/nvim/runtime/plugin/matchparen.vim
015.173  000.471  000.471: sourcing /usr/share/nvim/runtime/plugin/netrwPlugin.vim
015.460  000.105  000.105: sourcing /usr/share/nvim/runtime/autoload/remote/host.vim
015.643  000.092  000.092: sourcing /usr/share/nvim/runtime/autoload/remote/define.vim
015.701  000.387  000.190: sourcing /home/jonathf/.local/share/nvim/rplugin.vim
015.705  000.496  000.108: sourcing /usr/share/nvim/runtime/plugin/rplugin.vim
015.815  000.087  000.087: sourcing /usr/share/nvim/runtime/plugin/shada.vim
015.859  000.019  000.019: sourcing /usr/share/nvim/runtime/plugin/spellfile.vim
015.992  000.113  000.113: sourcing /usr/share/nvim/runtime/plugin/tarPlugin.vim
016.077  000.059  000.059: sourcing /usr/share/nvim/runtime/plugin/tohtml.vim
016.111  000.015  000.015: sourcing /usr/share/nvim/runtime/plugin/tutor.vim
016.254  000.126  000.126: sourcing /usr/share/nvim/runtime/plugin/zipPlugin.vim
016.259  000.720: loading plugins
016.313  000.054: loading packages
016.346  000.033: loading after plugins
016.356  000.010: inits 3
018.849  002.493: reading ShaDa
450.274  431.212  431.212: sourcing /home/jonathf/.config/nvim/plugged/Recover.vim/autoload/recover.vim
450.349  000.288: opening buffers
450.378  000.029: BufEnter autocommands
450.384  000.005: editing files in windows
450.465  000.081: VimEnter autocommands
450.469  000.004: UIEnter autocommands
450.471  000.002: before starting main loop
451.540  001.069: first screen update
451.543  000.003: --- NVIM STARTED ---

I've tested both a minimal and my full rc setup without the recover plugin, and then everything is fast again.

Failed recovery

rm -rf /tmp/uh-oh && mkdir $_ && cd $_ && wget http://rking.sharpsaw.org/...Makefile.swp && vim ...Makefile

If I run that then let recover.vim handle it, I get nothing recovered.

If I abort, then r through the normal means, it recovers.

Thanks!

Make it easy please

Nice plugin, so often we need to recover, save the recovered file, exit vim, check changes with diff, then replace the original file with the recovered one. 👍

Most of the time after checking the diff, we obviously only want to replace the current file by the newest version from the swap file (or to discard it).

Could you please document how to do it in the first lines of :h RecoverPlugin ? or implement something like ":RecoveryRetain" and ":RecoveryDiscard" ?

Thanks in advance :-)

For my first try, after losing ten minutes in the documentation (being unaware that documentation for the "merge" commands mentionned could be displayed with :h merge) I messed up with merge commands I do not masterize yet and lost my small change after :RecoveryPluginFinish... 🎱

Zero diff = zero prompt

If we could solve #12 well enough to be sure no other vim owns the file, then it would be nice if it would:

Check for no diffs from .sw? file and just delete the thing.

Probably it should show a message that it happened (perhaps with a timestamp
of the swapfile), but other than that, just roll on.

Open read-only option

Sometimes you know why there's a swap file and don't care, so it'd be nice if you didn't have to hit 'a' then 'o' to get to a read-only view.

Showing original recovery menu when pressing Ctrl-C

Imagine that file is already edited in some vim's instance. When you mistakenly open same file in another vim's instance then Recover menu is shown, and it has only 2 variants: Show diffs or No. In this case pressing Yes can delete swap file (which is not good), pressing No will show read-only buffer. Original vim's recovery menu will show more possibilities: Open, Edit, Recover, Quit, Abort. In normal situation i would choose Q or A, but Recover won't propose those variants.

Fortunately pressing Ctrl-C in Recover menu will show up original menu but it is not known from Recover menu. Maybe it makes sense just to add into the Recover menu a line like

Press Ctrl-C to enter vim's recovery menu

to make people know that they can choose from all variants?

Some viminfo history reset

With 'history' greater than 50, and more than fifty entries for the command line history in .viminfo, opening the same file in two instances of Vim will reset the saved history to 50. The real world use case that I keep getting this is when I do a vimdiff with two files, one of which I have open already in some other Vim instance. I lose my older (but useful!) history.

With only "set history=5000" in vimrc, only Recover.vim installed, and more than fifty ":" entries in viminfo (grep -c '^:' .viminfo), steps to replicate:

  1. vim wibble
  2. Open another window, or put the current vim into the background
  3. vim wibble - the same file. The "Please choose:" prompt appears
  4. Note that the number of ":" entries in viminfo have reduced to 50

Error message when opening file in windows

First of all, thank you for your plugins and work in vim.
I read the mailing list almost everyday, I find the discussions interesting, but I usually have nothing to contribute :)

When opening a file with gvim in windows (windows 8, 64 bit) I get the following error message:

Error detected while processing function recover#ConfirmSwapDiff:
line 34:
E484: Can't open file C:\Users\Alatar\AppData\Local\Temp\VIo10B1.tmp
'TERM' is not recognized as an internal or external command,
operable program or batch file.

I also have the different menu with the options diff, quit...
I choose diff and the script tells me no difference exits and I can delete the file.
So the plugin works fine, it just gives me an error message...

Maybe there is a way of avoiding this?

Thanks!

No diff == Default to delete

If there is no diff from the swpfile, it's basically a useless file, is it not?

So it would make sense if you could just hit <enter> and get the [Y]es to delete.

Entering Ex mode. Type "visual" to go to Normal mode.

I suspect the following isn't normal:

".vimrc.local"
".vimrc.local" 8 lines, 303 characters
Entering Ex mode.  Type "visual" to go to Normal mode.
:
Please choose:
D[i]ff, (O)pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort, (D)elete:

I'm getting with Vim 7.4 installed with homebrew, pathogen commit 1270dceb1fe0ca35f8b292c7b41b45b42c5a0cc1, and Recover.vim commit cfe49d8a735282e711cf1437e0fd0150d8fe4087

I deleted all other plugins.

recover#RecoverFinish() does not delete swap file

In my vimrc, I have the set directory=$VIMHOME/tmp/swapfiles// statement to keep my development folders clear of swap files. I am running vim 7.4.712 on MacOSX. After vim crashes, my preferred choice is to use the Diff in your plugin to examine the differences. When I'm done, using either :RecoverPluginFinish or :RecoverPluginGet, I think all is well. That is, until I edit the file again, and I go through the same operation. I traced it down to the call delete(fnameescape(swapname)) statement in recover#RecoverFinish(). The delete() function is returning a -2.

At the time the error occurred, the value of swapname is /Users/prunninger/.vim/tmp/swapfiles//%Users%prunninger%junk%foo.txt.swp, which fnameescape changes to /Users/prunninger/.vim/tmp/swapfiles//\%Users\%prunninger\%junk\%foo.txt.swp.

As I stated in my StackOverflow question, I suspect bad escaping, pointing to a nonexistent file, rather than a permission issue.

bad behaviour with Powerline

Hi.

Nice plugin! Only i found that it breaks Powerline status line when :FinishRecovery issued. The problem arises from s:ModifySTL() when argument enable is 0. Actually it tries to restore &stl from value of s:ostl - but this value, created upon plugin's start has nothing to do with value of &stl on :FinishRecovery moment if Powerline is installed - Powerline just changes it to something like %!Pl#Statusline(0,1) and restoring &stl from older s:ostl breaks Powerline status line.

Some workaround could be: store also new value of &stl in variable, say, s:nstl and then, when restoring &stl, check if it changed - if it changed (e.g. By Powerline) then just do nothing.

fu! s:ModifySTL(enable) "{{{1
if a:enable
" Inject some info into the statusline
:let s:ostl=&stl
:let s:nstl=substitute(&stl, '%f', "\0 %{exists('b:mod')?('['.b:mod.']') : ''}", 'g')
:let stl=s:nstl
else
" Restore old statusline setting
if exists("s:ostl") && s:nstl == &stl
let &stl=s:ostl
endif
endif
endfu

This workaround won't break old behaviour and will fix the issue with Powerline (it works for me).

doesn't recognize .swo etc

If there somehow are additional swap files beyond the first .swp, then after deleting the .swp, this ought to ideally see if there are other swap files also.

Error detected while processing function <SNR>37_CheckSwapFileExists:

Hi,

When swap file exists, I am shown this error.

Error detected while processing function <SNR>37_CheckSwapFileExists:
line    8:
E325: ATTENTION

Line 37 in CheckSwapFileExists is simply obtaining the name of the swapfile.

redir => a | sil swapname |redir end

I am not sure what's wrong and what info do I need to provide to nail down the issue.

[Bug] Unknown function: trim

This modification from PR #69 gives me an error every time I open vim

let a=trim(execute('swapname'))

Error detected while processing function recover#CheckSwapFileExists[4]..<SNR>87_Swapname:
line    4:
E117: Unknown function: trim
E15: Invalid expression: trim(execute('swapname'))
line    8:
E121: Undefined variable: a
E15: Invalid expression: a[1:] == 'No swap file'

Is this a vim version issue? I am using vim version 8.0.1453.

Screen not shown

I recently switched from NVIM v0.2.0-1171-g4566f7c to NVIM v0.3.1-1-g489d32f2b.

Now, after starting the plug-in only shows an empty screen. Pressing i still triggers the diff.
If I press <ESC> the usual info screen appears.

Have no v:progpath in older vim

E121: Undefined variable: v:progpath

Seems it was introduced it in 7.4.234, see http://ftp.nluug.nl/editors/vim/patches/7.4/7.4.234
That var is cool, as you don't even have to have Vim in your path to setup inverse and forward search for example.
But for earlier version consider using v:progname instead, that has been around since Vim 6.
As long as Vim is in your path, all will work even with v:progname.

if v:version > 704 || (v:version == 704 && has('patch234')) ...

wincmd and \n does not work for me

Hi,

I tried your plugin and I'm thrilled! I found small glitch though. When I recover a file, I can see in the command line this text with cursor waiting for input at the end.

:wincmd l:0

'feedkeys' help says: feedkeys("") simulates pressing of the key

Changing for example feedkeys(":wincmd l\n", 't') into feedkeys(":wincmd l", 't') fixes the issue for me. There is a lot of feedkeys through the plugin and for example the ones DiffRecoveredFileOld seems to work fine to me. But it seems that it won't do any harm fixing all of those according to documentation.

Thank you
__
Vlad

shortcut

I find quite unfortunate that at startup you don't have to use D, I'm quite sure that I'd press more often D than I, thus canceling the backup and making this plugin very dangerous :-)

D[i]ff

prompt shows only when the swap is dirty?

Is it correct that now the "recover" prompt is shown only when the swap file is dirty? i.e. there are unsaved changes in the main buffer?
It used to be that in the past when a file is opened more than once at a time Recover would detect the presence of an (old) swap file and offer to delete the (old) swap file if no differences existed between the two. This was really useful. It offered a convenient way to delete the old swapfile. Particularly useful if/when vim crashes and leaves a swap file behind, etc. It was also useful to know that a given file is open in more than one vim instance..

Now if same file is opened multiple vim instances at the same time, recover doesn't prompt anything to indicate that this is the case (unless the swap file is dirty)?
I think this is likely introduced via commits f545fa8 and specifically 9924586

Not sure if Recover knows if a swap file exists but the process (vim) that created the swap file is no longer around, then in that case offer to diff and subsequently to delete the old swap file?

Thanks.

request to avoid 'sleep'

On Windows, this line:

call system(cmd)

Takes 3 seconds. (though if I execute that command in cmd.exe it's less than 1 second)

I'm not sure how to make it faster, but it would reduce the pain if one didn't also need to wait another 2 seconds here:

https://github.com/chrisbra/Recover.vim/blob/master/autoload/recover.vim#L225

Would you consider removing that sleep 2 call? The message "Found SwapFile, opening file readonly!" is written to the :mes log already, and the user made the choice so presumably doesn't need a 2-second notification of that choice immediately after.

[contrib] cvim does not work correctly on filenames containing spaces

Hello,

Steps to reproduce:

  1. cd /tmp
  2. vim 'testing file.txt'
  3. Write some text.
  4. Wait a bit, so that vim will dump everythg to the swapfile.
  5. Kill this vim instance with SIGKILL (e.g. Ctrl+Z, jobs -l, kill 30464 -s SIGKILL).
    (actually this sequence of commands does make vim save the file somehow)
  6. cvim

Vim will then print the following error message:

E305: Nie znaleziono pliku wymiany dla .testing
Naciśnij ENTER lub wprowadź komendę aby kontynuować

Rough translation:

E305: Cannot find swap file for .testing
Press ENTER

mateusz@mateusz-ubuntu:/tmp$ cvim
Found: 1 swap file (mtime):
  .testing file.txt.swp (11/11/14 12:30:56)
2 plików do edycji
Skipping .testing file.txt.swp: vim exited with error code 1
mateusz@mateusz-ubuntu:/tmp$ ll

Fortunately this does not destroy any data (though I did not do extensive tests).

Cvim was modified a bit to disable checking for a running vim instance as I did not want to install psutils. This should not affect the described behaviour, though.

Clash with fencview

Not actually a bug but rather interesting behaviour. I have installed plugin fencview (http://www.vim.org/scripts/script.php?script_id=1708). With this if i have a swap file Recover behaves not as expected: it shows its original dialog and when i press <Enter> it shows vim's recover menu and when i press <Enter> again it shows FencView errors. All this looks like

E325: ATTENTION
Found a swap file by the name ".Sprint2.txt.swp"
          owned by: lyokha   dated: Thu Aug 15 18:28:51 2013
         file name: ~lyokha/Sprint2.txt
          modified: YES
         user name: lyokha   host name: localhost.localdomain
        process ID: 15079 [not existing]


 Processing...  100% (ctrl+c to stop)
Found a swap file by the name ".Sprint2.txt.swp"
          owned by: lyokha   dated: Thu Aug 15 18:28:51 2013
         file name: ~lyokha/Sprint2.txt
          modified: YES
         user name: lyokha   host name: localhost.localdomain
        process ID: 15079
While opening file "Sprint2.txt"
             dated: Thu Aug 15 18:11:42 2013

(1) Another program may be editing the same file.  If this is the case,
    be careful not to end up with two different instances of the same
    file when making changes.  Quit, or continue with caution.
(2) An edit session for this file crashed.
    If this is the case, use ":recover" or "vim -r Sprint2.txt"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file ".Sprint2.txt.swp"
    to avoid this message.

Swap file ".Sprint2.txt.swp" already exists!
"Sprint2.txt" [readonly] 34L, 2101C
Error detected while processing function <SNR>43_EditAutoEncoding..<SNR>43_FencDetectFileEncoding:
line   92:
E325: ATTENTION
Error detected while processing function <SNR>43_EditAutoEncoding:
line   40:
E171: Missing :endif
Press ENTER or type command to continue

and after that a single buffer opens without the diff mode.

I found that i can suppress this issue by adding in my .vimrc line

" disable fencview autodetection as it clashes with Recover plugin
let g:fencview_autodetect = 0

Cheers, Alexey.

Bug: rubbish message in neovim

Seems like it somehow messed out by reasons of migrating to shada.
Check out if it possible to fix, please.
As 'diff' case saved me innumerable times, but output makes sad:)

chdir(/home/amerlyq/aura/airy/cfg/term/vim/cfg/plugins)                             
chdir(/home/amerlyq/.vim/cfg/plugins)                                               
chdir(/home/amerlyq/aura/airy/cfg/term/vim/cfg/plugins)                             
Reading ShaDa file "/home/amerlyq/.local/share/nvim/shada/main.shada" info marks old
files^[[?1049h^[[H^[[J^[[?2004h^[[8;24;80t^[[H^[[J^[[1;1H^[[1;1H^[[?1002h^[[?1006h^[
[24;1Hchdir(/home/amerlyq/aura/airy/cfg/term/vim/cfg/plugins)^[[24;56H^[[1;24r^[[1;1
H^[[M^[[1;24r^[[24;56H^[[24;1Hchdir(/home/amerlyq/.vim/cfg/plugins)^[[1;24r^[[1;1H^[
[M^[[1;24r^[[24;38H^[[24;1Hchdir(/home/amerlyq/aura/airy/cfg/term/vim/cfg/plugins)^[
[1;24r^[[1;1H^[[M^[[1;24r^[[24;56H^[[24;1H"~/.vim/cfg/plugins/environment.yml" ^[[24
;38H^[[24;1H"~/.vim/cfg/plugins/environment.yml" 37L, 1245C^[[1;24r^[[1;1H^[[M^[[1;2
4r^[[24;48H^[[24;1HReading ShaDa file "/home/amerlyq/.local/share/nvim/shada/main.sh
ada" marks ^[[?1002h^[[?1006h^[[1;24r^[[1;1H^[[M^[[1;24r^[[24;77H^[[24;1HEntering Ex
 mode.  Type "visual" to go to Normal mode.^[[1;24r^[[1;1H^[[M^[[1;24r^[[24;55H^[[24
;1H:^[[24;2H^[[24;2H^[[24;1H^[[1;24r^[[1;1H^[[M^[[1;24r^[[24;1HWriting ShaDa file "/
home/amerlyq/.local/share/nvim/shada/main.shada"^[[24;70H^[[24;1H^[[2 q^[[?1002l^[[?
1006l^[[m^O^[[?1049l^[[?2004l                                                       
Swap and on-disk file seem to be identical

Auto-edit if `still running` and no diffs

Hi, @chrisbra ! I'm still over here, happily using Recover.vim.

I did have one thing that I think would help me go faster:

If there is an "already running" vim editor, but its buffer is unmodified, then I certainly don't want a prompt: I just want to go into writeable mode on the file, and exit later. (That other vim can automatically reload the buffer on its own).

I haven't pawed through the code… how hard do you think this would be to implement as an optional behavior of Recover.vim? Thanks!

Diff message closed messily without changing/deleting anything?

When I open a certain file that has a .swp file hanging around, the swap file detected message shows up briefly before nearly instantly changing to the editor with bits and pieces of the swap message still hanging around. The editor remains this way until I perform almost any action.

Example:

recovery-1

Better-ish version here.

It isn't obvious in the gif, but between the file opening and the screen returning to a normal state I'm mashing the k key. The other movement keys appear to also make the screen return to a normal state.

Something similar occurs when cepa.hpp is empty:

recovery-2

Link

I'm on macOS 10.13 beta. This happens on the built-in vim, but not on vim installed from Homebrew nor Neovim. I'm not sure whether this should be considered an issue for here or for vim itself, so let me know if it's someone else's problem.

Here are the files in question. I had to change the file extensions to get GitHub to allow me to attach the files. Just strip the .txt off and add a leading dot to the .swp file.

cepa.hpp.txt
cepa.hpp.swp.txt

git bisect tells me that the problematic commit is 35ca3f5ec263c5b1dbba2c3e373306e20343227d, but it's not immediately obvious to me what the problem is, otherwise I would have submitted a PR instead of opening an issue.

Result of macOS's vim --version:

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jul  7 2017 13:44:26)
Included patches: 1-642
Compiled by [email protected]
Normal version without GUI.  Features included (+) or not (-):
+acl             +file_in_path    -mouse_sgr       +tag_old_static
-arabic          +find_in_path    -mouse_sysmouse  -tag_any_white
+autocmd         +float           -mouse_urxvt     -tcl
-balloon_eval    +folding         +mouse_xterm     -termguicolors
-browse          -footer          +multi_byte      +terminfo
+builtin_terms   +fork()          +multi_lang      +termresponse
+byte_offset     -gettext         -mzscheme        +textobjects
+channel         -hangul_input    +netbeans_intg   +timers
+cindent         +iconv           +num64           +title
-clientserver    +insert_expand   +packages        -toolbar
-clipboard       +job             +path_extra      +user_commands
+cmdline_compl   +jumplist        -perl            +vertsplit
+cmdline_hist    -keymap          +persistent_undo +virtualedit
+cmdline_info    +lambda          +postscript      +visual
+comments        -langmap         +printer         +visualextra
-conceal         +libcall         -profile         +viminfo
+cryptv          +linebreak       +python/dyn      +vreplace
+cscope          +lispindent      -python3         +wildignore
+cursorbind      +listcmds        +quickfix        +wildmenu
+cursorshape     +localmap        +reltime         +windows
+dialog_con      -lua             -rightleft       +writebackup
+diff            +menu            +ruby/dyn        -X11
+digraphs        +mksession       +scrollbind      -xfontset
-dnd             +modify_fname    +signs           -xim
-ebcdic          +mouse           +smartindent     -xpm
-emacs_tags      -mouseshape      +startuptime     -xsmp
+eval            -mouse_dec       +statusline      -xterm_clipboard
+ex_extra        -mouse_gpm       -sun_workshop    -xterm_save
+extra_search    -mouse_jsbterm   +syntax
-farsi           -mouse_netterm   +tag_binary
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc   -L/usr/local/lib -o vim        -lm -lncurses  -liconv -framework Cocoa

Result of brew's vim --version:

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled May 25 2017 08:55:37)
MacOS X (unix) version
Included patches: 1-604
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl             +file_in_path    +mouse_sgr       +tag_old_static
+arabic          +find_in_path    -mouse_sysmouse  -tag_any_white
+autocmd         +float           +mouse_urxvt     -tcl
-balloon_eval    +folding         +mouse_xterm     +termguicolors
-browse          -footer          +multi_byte      +terminfo
++builtin_terms  +fork()          +multi_lang      +termresponse
+byte_offset     -gettext         -mzscheme        +textobjects
+channel         -hangul_input    +netbeans_intg   +timers
+cindent         +iconv           +num64           +title
-clientserver    +insert_expand   +packages        -toolbar
+clipboard       +job             +path_extra      +user_commands
+cmdline_compl   +jumplist        +perl            +vertsplit
+cmdline_hist    +keymap          +persistent_undo +virtualedit
+cmdline_info    +lambda          +postscript      +visual
+comments        +langmap         +printer         +visualextra
+conceal         +libcall         +profile         +viminfo
+cryptv          +linebreak       +python          +vreplace
+cscope          +lispindent      -python3         +wildignore
+cursorbind      +listcmds        +quickfix        +wildmenu
+cursorshape     +localmap        +reltime         +windows
+dialog_con      -lua             +rightleft       +writebackup
+diff            +menu            +ruby            -X11
+digraphs        +mksession       +scrollbind      -xfontset
-dnd             +modify_fname    +signs           -xim
-ebcdic          +mouse           +smartindent     -xpm
+emacs_tags      -mouseshape      +startuptime     -xsmp
+eval            +mouse_dec       +statusline      -xterm_clipboard
+ex_extra        -mouse_gpm       -sun_workshop    -xterm_save
+extra_search    -mouse_jsbterm   +syntax
+farsi           +mouse_netterm   +tag_binary
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: clang   -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o vim        -lncurses -liconv -framework Cocoa   -mmacosx-version-min=10.12 -fstack-protector-strong -L/usr/local/lib  -L/usr/local/Cellar/perl/5.24.1/lib/perl5/5.24.1/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc -F/usr/local/opt/python/Frameworks -framework Python   -lruby.2.4.1 -lobjc

recovery-1

Cursor positioned in wrong window when one or more windows were autoopen

I found that 'wincmd l' workaround must not be triggered when there are windows to autoopen (e.g. tagbar or NERDtree etc.). Simple fix is to additionally check if number of open windows is less than 3 (i.e. there are only 2 windows to diff). Here is a very simple patch against current repo version:

--- autoload/recover.vim    2012-04-20 04:42:54.000000000 +0400
+++ autoload/recover.vim.new    2012-06-17 17:41:51.320910297 +0400
@@ -76,9 +76,10 @@
        " Not sure, why this needs feedkeys
        " Sometimes cursor is wrong, I hate when this happens
        " Cursor is wrong only when there is a single buffer open, a simple
-       " workaround for that is to check if bufnr('') is 1: in this case
-       " ':wincmd l\n:0\n' must be fed
-       if bufnr('') == 1
+       " workaround for that is to check if bufnr('') is 1 and total number
+       " of windows in current tab is less than 3 (i.e. no windows were
+       " autoopen): in this case " ':wincmd l\n:0\n' must be fed
+       if bufnr('') == 1 && winnr('$') < 3
        call feedkeys(":wincmd l\n", 't')
        endif
        call feedkeys(":0\n", 't')

I tested this in different conditions (with and without autoopen windows, in current window / in new tagbar etc.): it seems to work fine.

Cheers, Alexey.

Change "on-disk version" to something more precise

After doing a recover-diff, the manually-saved file is referred to as name-of-file (on-disk version). However, I find this wording ambiguous, because both the manually-saved file and the .swp file are "on disk".

I was wondering whether this could be changed to something more precise, perhaps manually-saved version?

this plugin seems to no longer work

been using this plugin happily for awhile, but it stopped working on my mbp. here's the output when trying to open an already open file (shows the E325 error and the swap file options are the typical ones):

"../Makefile" 44L, 1687B
Error detected while processing BufWinEnter Autocommands for "*"..function recover#CheckSwapFileExists[8]..<SNR>67_SetSwapfile:
line    3:
E325: ATTENTION
Found a swap file by the name "~/.vim/tmp//%Users%user%.vim%bundle%Recover.vim%Makefile.swp"
          owned by: user   dated: Tue Nov 09 20:36:01 2021
         file name: ~user/.vim/bundle/Recover.vim/Makefile
          modified: no
         user name: user   host name: xxx.local
        process ID: 19486 (STILL RUNNING)
While opening file "../Makefile"
             dated: Mon Feb 15 16:01:51 2021

(1) Another program may be editing the same file.  If this is the case,
    be careful not to end up with two different instances of the same
    file when making changes.  Quit, or continue with caution.
(2) An edit session for this file crashed.
    If this is the case, use ":recover" or "vim -r ../Makefile"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file "/Users/user/.vim/tmp//%Users%user%.vim%bundle%Recover.vim%Makefile.swp"
    to avoid this message.

Swap file "~/.vim/tmp//%Users%user%.vim%bundle%Recover.vim%Makefile.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort: 

macOS 12.0.1
vim --version (system /usr/bin/vim)

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Oct  1 2021 22:47:36)
macOS version - x86_64
Included patches: 1-2671
Compiled by [email protected]
Normal version without GUI.  Features included (+) or not (-):
+acl               -farsi             +mouse_sgr         +tag_binary
-arabic            +file_in_path      -mouse_sysmouse    -tag_old_static
+autocmd           +find_in_path      -mouse_urxvt       -tag_any_white
+autochdir         +float             +mouse_xterm       -tcl
-autoservername    +folding           +multi_byte        -termguicolors
-balloon_eval      -footer            +multi_lang        +terminal
-balloon_eval_term +fork()            -mzscheme          +terminfo
-browse            -gettext           +netbeans_intg     +termresponse
+builtin_terms     -hangul_input      +num64             +textobjects
+byte_offset       +iconv             +packages          +textprop
+channel           +insert_expand     +path_extra        +timers
+cindent           +ipv6              -perl              +title
-clientserver      +job               +persistent_undo   -toolbar
+clipboard         +jumplist          +popupwin          +user_commands
+cmdline_compl     -keymap            +postscript        -vartabs
+cmdline_hist      +lambda            +printer           +vertsplit
+cmdline_info      -langmap           -profile           +virtualedit
+comments          +libcall           -python            +visual
-conceal           +linebreak         -python3           +visualextra
+cryptv            +lispindent        +quickfix          +viminfo
+cscope            +listcmds          +reltime           +vreplace
+cursorbind        +localmap          -rightleft         +wildignore
+cursorshape       -lua               +ruby/dyn          +wildmenu
+dialog_con        +menu              +scrollbind        +windows
+diff              +mksession         +signs             +writebackup
+digraphs          +modify_fname      +smartindent       -X11
-dnd               +mouse             -sound             -xfontset
-ebcdic            -mouseshape        +spell             -xim
-emacs_tags        -mouse_dec         +startuptime       -xpm
+eval              -mouse_gpm         +statusline        -xsmp
+ex_extra          -mouse_jsbterm     -sun_workshop      -xterm_clipboard
+extra_search      -mouse_netterm     +syntax            -xterm_save
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
Linking: gcc   -L/usr/local/lib -o vim        -lm -lncurses  -liconv -framework Cocoa 

Req. for Enhancement: auto-delete if no changes & nobody editing

It would really be a nice enhancement if a value could be set in my .vimrc ... something like
let g:Recover_delete_redundant_swaps=1

(or any other easy way to do it... )

If it didn't have the problem of not detecting file already being edited, I'd just hack in
Delete as a default in my local copy (not knowing much about vim scripting, I used the 'mod' (posted at end in 'diff -u' (patch) form), but it also deletes the file when someone else is editing it ;-(

(Usually me, but in some forgotten window that's been minimized... ;-))...

> diff -u recover.vim recover.vim
--- recover.vim.orig  2017-03-14 15:34:47.000000000 -0700
+++ recover.vim 2017-03-14 16:26:33.604411520 -0700
@@ -174,10 +174,11 @@
     if not_modified
  let p = 3
     else
- call inputsave()
- let p = confirm(info, cmd, (delete ? 7 : 1), 'I')
+    "  call inputsave()
+    "  let p = confirm(info, cmd, (delete ? 7 : 1), 'I')
     "    endif
- call inputrestore()
+        let p = 7
+    "  call inputrestore()
     endif
     let b:swapname=v:swapname
     if p == 1 || p == 3
@@ -213,7 +214,7 @@
     elseif p == 7
  " Delete Swap file, if not different
  call s:SwapChoice('d')
- call <sid>EchoMsg("Found SwapFile, deleting...")
+ "call <sid>EchoMsg("Found SwapFile, deleting...")
  " might trigger SwapExists again!
  call s:SetSwapfile()
     else

Specific Plugin Manager recommendation

We recommend installing with a plugin manager (there are several).

Might you recommend one? I want to install your plugin the recommended way, but perhaps I have not used a plugin manager before. Perhaps this plugin is not available in all plugin managers? I'm using Debian 12.

/proc file path misses a slash

Hello.

After last update i am getting following error when a file is already open:

Обнаружена ошибка при обработке function recover#ConfirmSwapDiff:
строка   20:
E484: Невозможно открыть файл /proc19545/status
E684: list index out of range: 0
E116: Параметры для функции matchstr(readfile(proc)[0], '^Name:\s*\zs.*') заданы неверно
E15: Недопустимое выражение: matchstr(readfile(proc)[0], '^Name:\s*\zs.*')

(it says that it cannot open file /proc19545/status). Next simple patch fixes the issue:

--- autoload/recover.vim    2012-11-22 12:22:27.267845303 +0400
+++ autoload/recover.vim.new    2012-11-22 12:22:17.473710144 +0400
@@ -119,7 +119,7 @@
    " try to get processname from pid
    let pid_pat = 'process ID:\s*\zs\d\+'
    let pid = matchstr(msg, pid_pat)+0
-   let proc = '/proc'. pid. '/status'
+   let proc = '/proc/'. pid. '/status'
    if !empty(pid) && isdirectory('/proc')
        let pname = 'not existing'
        if filereadable('/proc/'. pid. '/status')

Cheers, Alexey.

Why not offer to "[C]ompare" instead of "D[i]ff"?

The name and hot key offered by the "Diff" operation are hardly intuitive. There is even an open issue (#57) about it. I thought maybe "Compare" could be a better label.

Pro:

  • "Compare" is a well known word in English. "Diff" is listed in some dictionaries as slang.
  • The letter "C" is free in the dialogue offered when recovering a file. Pressing it currently has no effect at all, I checked. (I have Vim 8.1.)

Contra:

  • Habitual users will have to re-learn.

If there is consensus, I can take it upon myself to craft a patch and make a pull request.

Default dialog on "Diff"

When another vim has the file open, and you choose "[D]iff", the newcomer vim still goes through the default vim swpfile dialog.

make it somehow more obvious in README that it's not `D`?

I kept hitting D trying to make this work and shocked at how it would just delete the swp instead of open a diff. Arg. Stupid me. But still, somehow adding a really obvious bold bit to the README saying "using i, not D!!!" would be appropriate for this plugin that is liable to this confusion.

Anyway, thanks, it works great!!

presenting unrelated swap file

After loading a file after accidentally killing vim, recover presented me with an irrelevant swap file. swap 1 is correct, swap 2 is not.

Swap File '/Users/me/.vim/tmp/swap//%Users%me%project%btodo.txt.swp' found:
Swap files found:
    In directory ~/.vim/tmp/swap//:
1.     /%Users%me%project%btodo.txt.swp
...
        file name: ~me/projects/todo.txt
...
        user name: me   host name: macmini
...
2.    %Users%r.swp
...
        file name: ~me/tmp/scratch.txt
...
        user name: me   host name: macpro
Enter number of swap file to use (0 or quit):

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

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:

Getting E382 Buftype Not Set error when I attempt to save

Thanks for Recover.vim. I love having the option to drop into a diff window on recover.

Currently, after I align the left and right windows with :diffget and :diffput, I try to save both windows with :wq. However, I get a Cannot write, 'buftype' option is set error. The only way to save is to first :set buftype=" ". Am I missing something?

Also, what what be your opinion of Recover.vim automatically deleting the swap file as part of this process?

Wrong command names in recoverPlugin.txt, and confusion

Hello, great plugin.
In doc/recoverPlugin.txt, I noticed some mentions of commands with "RecoveryPlugin" at the beginning, they should start with "RecoverPlugin".

Also, I am really confused by the command "RecoverPluginGet".
The help text says:

Will get all changes from the recovered swapfile put them in the buffer and
finish diff mode off.

But it doesn't get anything from the swapfile.
You end up with a buffer with the regular file content.
Maybe it would be better to call it "RecoverPluginDiscard"?
Because that is what the option seems to be doing, it discards the swapfile.
Or adjust the help text to "Will get the regular on-disk version of the file and discard the swapfile"?

Feature Request: Remove .swp file

So I would love to use this plugin more, but I find myself skipping it and just editing or recovering manually.

My main issues is that i often just want to discard the .swp file. However, the diff is awesome to confirm that I'm not losing anything.

So instead of having to %diffg and then :FinishRecovery, it would be nice to have a ":TakeOnDiskVersion" or some such which simply removes the .swp and edits the on-disk version.

P.S. :FinishRecovery collides with :finish. kind of a pain...

Feel free to disregard. =)

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.