Tuesday, July 6, 2021

Re: Find unnamed swap file

Julius Hamilton wrote:
> I am using Gvim on Andronix, Android Linux, and it suddenly goes down
> sometimes. I can recover any documents that were named with the .swp file
> recovery menu. Is there any way I can search for .swp files for files that
> hadn't been initially saved and named yet?

In the shell, I use this to find "all" swap files:

find $HOME -type f -name \*.sw\?

It's a bit loose in that it catches files that don't start with ".",
and I've been known to use those to hide stuff from git (via "*.swp"
in .gitignore). And it misses swap files outside $HOME which can be
a big issue if you've configured vim to store them somewhere else.

The \? is there for the multiple name case. I've certainly had up to
five happen for *unnamed* swap files: ~/.swp ~/.swo ~/.swn ~/.swm ~/.swl
but it could also catch random unrelated suffixes.

There's `vim -r` to list swap files which searches . and various temp
directories, and _I think_ will search the configured swap directory
(":set dir=...") but the starting.txt help is not specific on that
point. It, for me, has issues in that it doesn't seach $HOME if not
currently in $HOME for those unamed files list above. And it is a bit
dumb in listing swap files that belong to other users in /tmp and
/var/tmp (multi-user systems may be rarer, but do still exist).

$ cd ~/public_html
$ vim -r
Swap files found:
In current directory:
-- none --
In directory ~/tmp:
-- none --
In directory /var/tmp:
1. .mutt-panix5-151-23155-13042905455779035101.swp
owned by: user-e dated: Mon Jun 07 20:51:09 2021
[cannot be opened]
2. .mutt-panix5-905-14293-633769003522717526.swp
owned by: user-d dated: Tue Jul 06 14:32:05 2021
[cannot be opened]
3. .mutt-panix5-905-26039-8429083450887969313.swp
owned by: user-d dated: Tue Jun 08 15:40:28 2021
[cannot be opened]
4. .nn.EuY9xy.swp
owned by: user-w dated: Mon Jun 07 13:28:17 2021
[cannot be opened]
In directory /tmp:
-- none --

$

Note total lack of the swap file for this reponse, which is in
$HOME/.letter.13891.swp

(I also see it misses an actual recovery file in ~ from an unexpected
reboot about a month ago.)

Elijah

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/4GKB942Z0GzfYm%40panix5.panix.com.

No comments: