checking spelling while editing

utzoo!decvax!duke!chico!harpo!mhtsa!alice!rab utzoo!decvax!duke!chico!harpo!mhtsa!alice!rab
Wed Jan 27 15:55:52 AEST 1982


It can be frustrating to perform spelling correction on a document using
a screen terminal.  The output of the spell command can be placed on a file
or viewed on the screen, but tends to get lost as the spelling errors
are corrected on the screen.
This note describes a way of using the vi editor to provide facilities to search
out spelling errors in a document, and to correct them using the full power
of vi.  It does not require the user to type in any of the misspelled words.
--------------

Include the following EXINIT line in your .profile file.

EXINIT='map #1 Gi/^V^["add at a|map #2 1G!Gvispell^V^['; export EXINIT

This line sets up function keys 1 and 2 to provide special spelling functions.
(The ^V and ^[ characters are ctrl-V and escape.
By changing the "map" commands in the EXINIT definition, it is possible
to use keys other than function keys 1 and 2 for these functions.)

When the user hits function key 2, the vi command
1G!Gvispell
is executed.
This pipes the entire file to the following "vispell" shell script:

tee /tmp/vis$$
echo SpellingList
spell /tmp/vis$$
rm /tmp/vis$$

The shell script returns the entire input file, with the word
"SpellingList" appended followed by the list of misspelled words produced
by the spell command.

Now function key 1 is usable.  Whenever function key 1 is pressed, the
following vi commands are executed  (comments in parens)

G	(go to end of buffer)
i/ esc	(insert a slash, terminate with escape)
"add	(delete this line into buffer a)
@a	(execute buffer a)

Thus the last line of the buffer is changed into a search command, deleted
from the buffer, and executed.
The user will see the first line in the file containing the misspelled word,
can make changes with any vi commands, and can continue searching for
other occurrences of the word with the vi "n" command.
Once "n" gives "Pattern not found", function key 1 can be used to search
for another word.

When the word "SpellingList" is searched for, the spelling correction process
is finished.

It is probably a good idea for the user to look over the spelling list
at the end of the buffer prior to using function key 1.  Any correct
words can be deleted before beginning to search for the misspelled ones.

      Rick Becker



More information about the Comp.unix.wizards mailing list