Spell-checking a buffer in vi. Need help.

Rouben Rostamian rostamia at umbc3.UMBC.EDU
Fri Mar 31 16:38:51 AEST 1989


Here is a questions that probably has been asked a hundred times in this
newsgroup.  My apologies to all old-timers.

To spell-check the current buffer in vi I do the following:
  1. 1G       [Go to the top of the current buffer]
  2. "byG     [Yank the current buffer and place it in the named buffer b]
  3. !Gspell  [Run (to the end of buffer) through spell]
              [The current buffer now is replaced by the output of
               spell (i.e., a list of misspelled words]
  4. "bP      [Insert the contents of the original buffer (from 
               the named buffer b) into the present buffer]

The net effect is that I obtain a list of my misspelled words appended to
the original buffer.

How do we automate this procedure?  It seems reasonable to bind the
4-step sequence above to one key, say to ^A, by:

map ^A  1G "byG !Gspell^M "bP

where ^M represents a carriage return.
But somehow this does not work.  For mysterious reasons the buffer b ends 
up empty after the execution, so I only get a list of my misspelled words and a
beep (a warning, I guess, that the buffer b is empty, so "bP cannot execute.)
I can recover my original buffer by pressing u, but then I lose the list
of misspelled words.  I will be thankful for any any explanation of why
this does not work and will welcome suggestions for fixes.

An ugly solution to the problem is redirect to output of the spell to a
temporary file then read in the temporary file into the buffer.  Are
there better solutions for spelling the buffer in vi?

-- 
Rouben Rostamian
Department of Mathematics                      e-mail:
University of Maryland Baltimore Counnty       Rostamian at umbc2.bitnet
Baltimore, MD 21228                            rostamia at umbc3.umbc.edu



More information about the Comp.unix.questions mailing list