Vim backup files

28 views
Skip to first unread message

Steve Litt

unread,
Oct 17, 2021, 6:18:57 PM10/17/21
to vim...@googlegroups.com
Hi all,

I've used Vim since the 20th century, and of course things keep getting
better, which means change. As I remember, back in the day, the Vim
backup files that began with a dot and ended with .swp were text files
containing what was in the window, and were automatically updated every
X number of seconds. This appears to no longer be the case.
.test.pl.swp appeared to be a binary file, so I couldn't just diff it
with the original.

In the past, after a crash, when I ran Vim on the file again, it gave
me a dialog box in which to choose to recover, ignore, quit, whatever.
This didn't happen in today's crash.

I tried using :rec in the main file, it said there was no recovery
file, and maybe changed the recovery file to .test.pl.swp.swp. I tried
a few other things, but I was always just one step behind and
eventually lost the swap files completely. Only one of them was
important, and I have a paper copy, so I should be OK.

After a crash, I'd like a way to know whether a swap file exists, and
whether it indicates any differences from what's in my buffer. Is there
a program that can do this for me, now that the dialog box doesn't
happen anymore?

Thanks,

SteveT

Steve Litt
Spring 2021 featured book: Troubleshooting Techniques of the Successful Technologist
http://www.troubleshooters.com/techniques

Shlomi Fish

unread,
Oct 18, 2021, 1:29:24 AM10/18/21
to Steve Litt, vim...@googlegroups.com
Hi Steve!

On Sun, 17 Oct 2021 18:18:46 -0400
Steve Litt <sl...@troubleshooters.com> wrote:

> Hi all,
>
> I've used Vim since the 20th century, and of course things keep getting
> better, which means change. As I remember, back in the day, the Vim
> backup files that began with a dot and ended with .swp were text files
> containing what was in the window, and were automatically updated every
> X number of seconds. This appears to no longer be the case.
> .test.pl.swp appeared to be a binary file, so I couldn't just diff it
> with the original.
>
> In the past, after a crash, when I ran Vim on the file again, it gave
> me a dialog box in which to choose to recover, ignore, quit, whatever.
> This didn't happen in today's crash.
>
> I tried using :rec in the main file, it said there was no recovery
> file, and maybe changed the recovery file to .test.pl.swp.swp. I tried
> a few other things, but I was always just one step behind and
> eventually lost the swap files completely. Only one of them was
> important, and I have a paper copy, so I should be OK.
>
> After a crash, I'd like a way to know whether a swap file exists, and
> whether it indicates any differences from what's in my buffer. Is there
> a program that can do this for me, now that the dialog box doesn't
> happen anymore?
>

I tried it now:

```
[shlomif@telaviv1 ~]$ -t dotfiles
shlomif[dotfiles]:$trunk$ git i
⇒ On branch master
⇒ Your branch is up to date with 'origin/master'.
⇒ Remotes:
origin g...@github.com:shlomif/shlomif-computer-settings.git (fetch)
origin g...@github.com:shlomif/shlomif-computer-settings.git (push)
shlomif[dotfiles]:$trunk$ ls
LICENSE README.asciidoc README.asciidoc~ shlomif-settings
shlomif[dotfiles]:$trunk$ gvim README.asciidoc
shlomif[dotfiles]:$trunk$ pkill gvim
Vim: Caught deadly signal TERM
Vim: preserving files...
shlomif[dotfiles]:$trunk$ Vim: Finished.

shlomif[dotfiles]:$trunk$ git i
⇒ On branch master
⇒ Your branch is up to date with 'origin/master'.
⇒ Remotes:
origin g...@github.com:shlomif/shlomif-computer-settings.git (fetch)
origin g...@github.com:shlomif/shlomif-computer-settings.git (push)
shlomif[dotfiles]:$trunk$ la
total 68K
drwxr-xr-x 8 shlomif shlomif 4.0K Oct 18 08:15 .git
-rw-r--r-- 1 shlomif shlomif 4.8K Apr 21 08:23 .gitignore
-rw-r--r-- 1 shlomif shlomif 4.7K Jul 27 2020 .gitignore~
-rw-r--r-- 1 shlomif shlomif 2.3K Oct 6 2018 .hgignore
-rw-r--r-- 1 shlomif shlomif 9 Oct 6 2018 LICENSE
-rw-r--r-- 1 shlomif shlomif 17 Oct 6 2018 .perltidyrc
-rw-r--r-- 1 shlomif shlomif 866 Jul 21 19:28 README.asciidoc
-rw-r--r-- 1 shlomif shlomif 866 Jul 21 19:27 README.asciidoc~
-rw-r--r-- 1 shlomif shlomif 12K Oct 18 08:14 .README.asciidoc.swp
drwxr-xr-x 41 shlomif shlomif 4.0K Oct 2 2020 shlomif-settings
drwxr-xr-x 4 shlomif shlomif 4.0K Sep 8 2020 .tidyall.d
-rw-r--r-- 1 shlomif shlomif 523 Sep 29 2020 .tidyallrc
-rw-r--r-- 1 shlomif shlomif 2.2K Jul 17 2020 .travis.yml
shlomif[dotfiles]:$trunk$

```

After I edited README.asciidoc again, I got this dialog:
https://www.shlomifish.org/Files/files/images/gvim-recover-Screenshot_2021-10-18_08-16-50.png
. Pressing "Recover" restored my unsaved changes.

So "works for me" with my vim config (
https://github.com/shlomif/shlomif-computer-settings/tree/master/shlomif-settings/vim-conf
).



> Thanks,
>
> SteveT
>
> Steve Litt
> Spring 2021 featured book: Troubleshooting Techniques of the Successful
> Technologist http://www.troubleshooters.com/techniques
>



--

Shlomi Fish https://www.shlomifish.org/
https://youtu.be/GoEn1YfYTBM - Tiffany Alvord - “Fall Together”

If Chuck Norris is disappointed by you not following his advice, he’ll survive.
On the other hand, you will not.
https://www.shlomifish.org/humour/bits/facts/Chuck-Norris/

Please reply to list if it's a mailing list post - https://shlom.in/reply .

Ruben Safir

unread,
Oct 18, 2021, 1:32:20 AM10/18/21
to vim...@googlegroups.com
On 10/18/21 01:29, Shlomi Fish wrote:
> Hi Steve!
>

how did you get past my spam filters
So many immigrant groups have swept through our town
that Brooklyn, like Atlantis, reaches mythological
proportions in the mind of the world - RI Safir 1998
http://www.mrbrklyn.com

DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002
http://www.nylxs.com - Leadership Development in Free Software
http://www2.mrbrklyn.com/resources - Unpublished Archive
http://www.coinhangout.com - coins!
http://www.brooklyn-living.com

Being so tracked is for FARM ANIMALS and and extermination camps,
but incompatible with living as a free human being. -RI Safir 2013

Bram Moolenaar

unread,
Oct 18, 2021, 5:31:34 AM10/18/21
to vim...@googlegroups.com, Steve Litt

Steve Litt wrote:

> I've used Vim since the 20th century, and of course things keep getting
> better, which means change. As I remember, back in the day, the Vim
> backup files that began with a dot and ended with .swp were text files
> containing what was in the window, and were automatically updated every
> X number of seconds. This appears to no longer be the case.
> .test.pl.swp appeared to be a binary file, so I couldn't just diff it
> with the original.

The backup file of file.txt is .file.txt~.
The .swp file is a binary format, although it does contain the text in
some way.

> In the past, after a crash, when I ran Vim on the file again, it gave
> me a dialog box in which to choose to recover, ignore, quit, whatever.
> This didn't happen in today's crash.
>
> I tried using :rec in the main file, it said there was no recovery
> file, and maybe changed the recovery file to .test.pl.swp.swp. I tried
> a few other things, but I was always just one step behind and
> eventually lost the swap files completely. Only one of them was
> important, and I have a paper copy, so I should be OK.
>
> After a crash, I'd like a way to know whether a swap file exists, and
> whether it indicates any differences from what's in my buffer. Is there
> a program that can do this for me, now that the dialog box doesn't
> happen anymore?

You can use "vim -r" to list swap files. If you see the one you need
then use "vim -r .file.txt.swp" to recover it.

--
hundred-and-one symptoms of being an internet addict:
184. You no longer ask prospective dates what their sign is, instead
your line is "Hi, what's your URL?"

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

rwmit...@gmail.com

unread,
Oct 18, 2021, 6:04:02 AM10/18/21
to vim_use
There are options to change the location and to disable backup files for certain filetypes.  My .vimrc file has:

      autocmd BufNewFile,BufRead /tmp/crontab* set nobackup nowritebackup

      set backupdir=~/Library/Caches/vim/backup//

      set backup


Reply all
Reply to author
Forward
0 new messages