Vi Pages - Answers

A collection of questions and answers about Vi.


Recovery info per email

When Vi dies while you were editing a file then you get a mail with this info:
You were editing a file without a name
at  on the machine ``zucchini'' when the editor was killed.
Since the file had no name, it has been named "LOST".

You can retrieve most of your changes to this file
using the "recover" command of the editor.
An easy way to do this is to give the command "vi -r ".
This method also works using "ex" and "edit".
Q: How is this mail generated? What is the mechanism behind this?

A: Jim Gottlieb (jimmy@info.com): "... when vi gets a HUP signal, it dumps its buffer, in some special format, to the program /usr/lib/expreserve ..."


Removing multiple lines

Does anyone have a mapping to remove multiple lines (ie lines which are exact duplictes of one another)? It would be good if the mapping does not use any external programs, such as "perl" or "uniq". The output should not be a sorted list of lines, if possible, ie it should be possible to resort the lines back into the previous order.

Workaround with Perl:

	perl -ne 'print unless $seen{$_}++'
More scripts in awk, sed, or perl are welcome, too!