Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site alice.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!alice!rab From: rab@alice.UucP (Rick Becker) Newsgroups: net.unix Subject: Re: Vi query Message-ID: <4259@alice.UUCP> Date: Mon, 2-Sep-85 08:03:45 EDT Article-I.D.: alice.4259 Posted: Mon Sep 2 08:03:45 1985 Date-Received: Tue, 3-Sep-85 01:36:46 EDT References: <220@ur-cvsvax.UUCP> Organization: Bell Labs, Murray Hill Lines: 71 Bill Vaughn of the University of Rochester asked: > Is there a way in 'vi' to search for the next instance of the > word in which the cursor is presently in using, say, a single > keystroke (obviously one could use the '/' and enter the word by hand) ? His intention was to provide an aid to spelling correction. In answer to his question, I am posting a technique for interactive spelling correction that I originally posted in Jan, 1982. (Wow, how time flies!) -------------- 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 (or modify your current EXINIT line or .exrc file) EXINIT='map #1 Gi/\<^V^[A\>^V^["add@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, begin word, terminate with escape) A\> esc (end of word, 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 alice!rab research!rab