greim@sbsvax.UUCP (Michael Greim) (07/19/88)
In <5473@super.upenn.edu> Brant Cheikes writes : >Problem: Abbreviations are expanded at all levels of vi. >This has been reproduced in both System V vi and BSD vi >(SVR2 and 4.3BSD respectively). > >Reproduce: Run vi, and set an abbreviation, say :ab foo FooBaz. >Now insert some text, anytime you type "foo", it will be replaced >by "FooBaz". This is fine. However, you can no longer ever search >for the string "foo", nor edit a file called "foo"--in all cases, >"foo" is expanded first to FooBaz. > >SO, is this a bug? Is there some way to search for abbreviation >strings? If a bug, is there a fix? It seems to me that abbreviations >should ONLY be expanded while in input mode. I think it is a bug, as the Ex Reference Manual (3.5/2.13) states explicitly : abbreviate word rhs abbr:ab Add the named abbreviation to the current list. When in input mode in visual, if word is typed as a complete word, it will be changed to rhs. The vi Manual is a little bit unclear here. It just gives an example : A fature similar to macros in input mode is word abbreviation. ... :ab eecs Electrical Engineering and Computer Sciences causes the word 'eecs' to always be changed into the phrase 'Electrical Engineering and Computer Sciences'. It does not say what is meant by 'always', so it is open to interpretation. There are two possiblities : 1.) as is; when vi reads in a line of text (i,c,a ... /,?,: commands) an abbreviation will be expanded to its long form. 2.) only when in input mode from i, c, a ... visual commands will an abbreviation be expanded. One can easily imagine a situation for each of these features to come in handy, like : 1.) I have an abbreviation like in the example above. I want to find instances of it, but I don't want to type the whole text. I have abbreviations, don't I? So I just type /eecs and get what I want. 2.) I have a lot of abbreviations and now I want to look for instances of strings having a string in common, which happens also to be an abbreviation. I am just happy that I can type /string and get what I want. If you want to have your vi with option 2, here is the diff for it: *** ex_vops2.c.old Tue Jul 19 17:59:12 1988 --- ex_vops2.c Tue Jul 19 17:46:43 1988 *************** *** 683,689 **** * Word abbreviation mode. */ cstr[0] = c; ! if (anyabbrs && gcursor > ogcursor && !wordch(cstr) && wordch(gcursor-1)) { int wdtype, abno; cstr[1] = 0; --- 683,689 ---- * Word abbreviation mode. */ cstr[0] = c; ! if (!splitw && anyabbrs && gcursor > ogcursor && !wordch(cstr) && wordch(gcursor-1)) { int wdtype, abno; cstr[1] = 0; If you come up with a new idea (and a fix) how to handle this problem, let me hear about it, Absorb, apply and enjoy, -mg -- +------------------------------------------------------------------------------+ | UUCP: ...!uunet!unido!sbsvax!greim | Michael T. Greim | | or greim@sbsvax.UUCP | Universitaet des Saarlandes | | CSNET: greim%sbsvax.uucp@Germany.CSnet| FB 10 - Informatik (Dept. of CS) | | ARPA: greim%sbsvax.uucp@uunet.UU.NET | Bau 36, Im Stadtwald 15 | | Phone: +49 681 302 2434 | D-6600 Saarbruecken 11, West Germany | +------------------------------------------------------------------------------+ | # include <disclaimers/std.h> | +------------------------------------------------------------------------------+