batch swap file recovery

22 views
Skip to first unread message

shawn wilson

unread,
Oct 15, 2017, 8:40:36 AM10/15/17
to vim_use
I lost some work in a git repo (it was deleted - I've recovered a
point in time - but vim has newer data). So, is there a way to give
vim a list of files and try to recover the newest version in the swap
file and close? I know, it may give old data, but this should be
pretty easy to pick out in git (based on additions/subtractions)?

something like:
find -type f -print0 | xargs -0 -i{} vim ..... {}

?

Christian Brabandt

unread,
Oct 15, 2017, 3:19:01 PM10/15/17
to vim_use
Do you have those swapfiles still around?

Christian
--
[Politiker] Ja, wir bezahlen ja die Leute dafür, daß sie sich
Gedanken machen, sonst könnten wir uns ja selber welche machen.
-- Dieter Hildebrand

shawn wilson

unread,
Oct 15, 2017, 3:21:52 PM10/15/17
to vim_use
On Sun, Oct 15, 2017 at 3:18 PM, Christian Brabandt <cbl...@256bit.org> wrote:
>
> On So, 15 Okt 2017, shawn wilson wrote:
>
>> I lost some work in a git repo (it was deleted - I've recovered a
>> point in time - but vim has newer data). So, is there a way to give
>> vim a list of files and try to recover the newest version in the swap
>> file and close? I know, it may give old data, but this should be
>> pretty easy to pick out in git (based on additions/subtractions)?
>>
>> something like:
>> find -type f -print0 | xargs -0 -i{} vim ..... {}
>
> Do you have those swapfiles still around?
>

Yes, every file probably doesn't have a swp/swo file, but everything I
want does.

shawn wilson

unread,
Oct 22, 2017, 5:32:51 PM10/22/17
to vim_use
Not sure if this may be useful for some type of faq or something, but
this did take me a little bit to figure out:

for i in $(find -type f -not -path "./.git/*"); do f="${i/.\/}"; echo
$f; \vim --cmd 'set backupdir=/home/swilson/.vim/swpfiles/' --cmd 'set
dir=/home/swilson/.vim/swpfiles/' --cmd recover -c wq -N -u NONE "$f";
done
Reply all
Reply to author
Forward
0 new messages