Is there a way (or are there any tools) to automate this highly manual
recovery process? I.e., given a set of .swp files, for each one
compare the recovered file with the original and discard the swp if
it's useless (leaving in place the ones that could not be
automatically pruned out)?
--
Yang Zhang
http://www.mit.edu/~y_z/
Here is one suggestion:
You can use the 'directory' setting to cause Vim to keep these files
in one place. You can read about the tradeoffs at
:help swap-file
:help 'directory'
--
Erik Falor
Registered Linux User #445632 http://counter.li.org
Just curious, why not
sed 's/\(.*\)\.swp$/\1/' | \
--
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
Sorry, couldn't help it since shell scripting is a hobby for me... :->
#! /bin/sh
find . -name '*.swp' -type f -exec sh -c '
swap=$1
dir=${swap%/*} # dirname
tmp=${swap##*/.} # trim leading path and dot
file=${dir}/${tmp%.swp} # original file, trim .swp
ofile=$file.tmp$$ # temporary "old file"
cp "$file" "$ofile"
vim -r "$file" -e -c wq
if cmp -s "$file" "$ofile"
then
mv "$ofile" "$file"
rm -f "$swap"
fi' sh {} \;