VI & spell

Jon H. LaBadie jon at jonlab.UUCP
Thu Nov 23 00:03:42 AEST 1989


In article <4525 at ski.cs.vu.nl>, maart at cs.vu.nl (Maarten Litmaath) writes:
> In article <740 at uc.msc.umn.edu> glex at uf.UUCP (Jeffrey Gleixner) writes:
> \I finally have gotten so sick of typo's that I want to run spell while in
> \vi, without exiting or suspending, the file.   So I wrote a small script (sp).
> \It takes the input from vi (:1,$!sp) and redirects it to a file, I run

I may have overlooked this suggestion in past articles.
If so, I apologize to regular readers.

I integrate spell and vi using the editor's own facilities.  My .exrc
file, or EXINIT parameter if you chose, contains the following function
key maping:

  map #1 :w^MGo-----  Output Of Spell Program  -----^M^[!!spell %^M

Note, the ^M sequence represents a real <RETURN> and the ^[ is a real
<ESC> character.  These may have to be entered by quoting them with
the editor's quoting character ^V, <CONTROL V>.

Now, the effect of all this.  Press function key number 1, your current
buffer is saved under the current name (:w^M).

Back in the editor, your cursor is moved to the end of the file (G) and
two lines are added to the buffer.  The first one is a separator, the
second one is blank (o-----  Output Of Spell Program  -----^M^[).

The blank line is passed to the spell program's standard input stream
which ignores is since we also give it a filename argument with the "%"
character.  The output of spell, when it finishes, replaces the blank
line in the buffer.

What we end up with then looks like this:

  some text in the unix file
  more text, maybe with a misteak
  the last line of text from the original file
  -----  Output Of Spell Program  -----
  misteak
  unix

Note, spell's output is in your editor buffer, not in some file, not
blasting away at your terminal screen.  Your cursor is on the first
"misspelled" word in the list.

Now, what do we do with the list?  First, if you are certain the
spelling is correct, simply delete the line from the list (dd).
This is useful if the "misspelled" word is a personal name or a
known acronym.

If you feel the word is misspelled, search for it:
  /misteak^M
correct it:
  cwmistake^[
repeat the search for a second occurrance.
  n
If you are back to spell output list, you have found each occurrance.
Delete the line from the list.  Otherwise, you are on a second
instance of the misspelling.  Correct it also but use the vi "dot"
command to repeat the last change to the buffer:
  .

BTW, to assist in the look-up of the correct spelling of words,
I wrote a short shell script, "spelltell", that accepts the initial
fragment of a word and prints all words in a dictionary that begin
with that fragment.  For example, here is a sample run:

  Enter an initial fragment of the word you are seeking: acro
  acrobacy
  acrobat
  acrobatic
  acrolein
  acronym
  acrophobia
  acropolis
  across
  acrostic
  Enter an initial fragment of the word you are seeking: ^D

Let me know if there is any interest.  You need 3 things,
 1. ksh
 2. a version of look(1) - one was posted to comp.sources.misc
 3. an ascii version of the dictionary

-- 
Jon LaBadie
{att, princeton, bcr}!jonlab!jon
{att, attmail, bcr}!auxnj!jon



More information about the Comp.unix.questions mailing list