[net.unix-wizards] editor reverse line bet

KEN%ORION.BITNET@WISCVM.WISC.EDU (Kenneth Ng) (10/10/86)

>P.S. A Challenge to those Other Editor users, I can write a vi macro to
>    reverse the words on a line.. can you?

Hm. I've only spent 15 minutes on this so it isn't perfect, but
for the sake of demonstration that it can be done I have done 3
"macros" on 3 different systems.  Unfortunately one of them I
cannot test since I no longer have an account on that system.
They are:
------------------------------------------------
XEDIT: (Yes that infamous IBM editor)

/* reverse the words on a line, for a Unix-Wizards bet */
'extract/curline'
old_line = curline.3    /* get the contents of current line */
new_line = ""
do while length(old_line) > 0
   /* break "old_line" apart into "word" and "rest" */
   parse value old_line with word rest
   new_line = word || " " || new_line  /* put it back together */
   old_line = rest
   end
'replace' new_line
exit
------------------------------------------------
EIES Interact (The custom editor for the NJIT based computerized
conferencing and communications center)

+own;+ownlu;+rem rev words on a line,for a Unix-Wizard bet
+open1,u,sp;+l a$:=itm(1,&1)
+l b$:=""
+loop
+test len(a$)>0;+exit
+l b$:=sub(a$,1,fnd(' ',a$),0)+b$
+l a$:=sub(a$,fnd(' ',a$)+1,0)
+endloop
+l itm(1,&1):=b$
+ret
------------------------------------------------
Finally, from my student days on an ancient Univac 90-80/4 mainframe
clunker, the system editor EDT(Note: this one is not tested since
I no longer have an active account on it):
@#l1=?
@#s1=#l1
@d#s2
@(loop)on#s1find' '
@#s3=#s1:#i0-#i1
@prefix #s2 with #s3
@delete #s1:#i0-#i1
@goto-(loop)
@create #l1 with #s2
-------------------------------------------------
Now for a little soap box time.  It seems to me that one of the
most powerful features of a text editor is the ability to write
custom programs with a language the editor can understand.  The
three editors mentioned above have such features.  Therefore
practically any needed function can be added easily.  This is the
one feature I find so lacking in VI(1).  The macro facility kinda
has this, but I haven't seen the functionality of a real programming
language in this editor.  What I'd really like to see is an editor
that has the repeat edit facility of vi, combined with the macro
editor capabilities of XEDIT.  Also, I'd like to see an editor
which minimizes screen updates, like WordStar.  Are there any?
Well, that's enough soap box time for me, the altitude is getting
me dizzy.

P.S. A friend of mine wrote an operating system simulator in the
macro language of the last editor.  It included job scheduling,
printer queueing, memory resource allocation, and cpu utilization.
Has anyone done THAT in vi?

Kenneth Ng
NJIT - CCCC; Newark, New Jersey 07102
Bitnet: ken@orion.bitnet (prefered )
Uucp: ihnp4!allegra!bellcore!argus!ken
      psuvax1!cmcl2!caip!andromeda!argus!ken (faster)

campbell@maynard.UUCP (Larry Campbell) (10/12/86)

In article <4508@brl-smoke.ARPA> KEN%ORION.BITNET@WISCVM.WISC.EDU (Kenneth Ng) writes:
>                     ...  What I'd really like to see is an editor
>that has the repeat edit facility of vi, combined with the macro
>editor capabilities of XEDIT.  Also, I'd like to see an editor
>which minimizes screen updates, like WordStar.  Are there any?

EMACS is all this and more.  And the best implementation of EMACS,
Gnu EMACS, is free.  Unfortunately, I can't use Gnu EMACS because
it's too big to run on an Intel pseudo-computer.  But it is the best.

I use Jove, a very nice EMACS subset that's small enough and fast
enough to run on the Intel "architecture".
-- 
Larry Campbell            MCI: LCAMPBELL   The Boston Software Works, Inc.
ARPA: campbell%maynard.uucp@harvard.ARPA   120 Fulton Street, Boston MA 02109
UUCP: {alliant,wjh12}!maynard!campbell     (617) 367-6846

pdg@ihdev.UUCP (P. D. Guthrie) (10/12/86)

>P.S. A friend of mine wrote an operating system simulator in the
>macro language of the last editor.  It included job scheduling,
>printer queueing, memory resource allocation, and cpu utilization.
>Has anyone done THAT in vi?
>

That reminded me of the nicest star trek game I ever played, that was
written in TV, a TOPS-20 editor.  Then I remembered that TV itself was
written in TECO (as was TOPS-20 EMACS).  Try *that* in VI.  Actually, vi
does have its place - editing over hokey networks that put out ^S/^Q
sequences that can't be turned off.

-- 

Paul Guthrie					We come in peace,
ihnp4!ihdev!pdg					We bring BEER!

bzs@bu-cs.BU.EDU (Barry Shein) (10/13/86)

Ok, time to be obnoxious.

This is unix-wizards. We use all editors; ed, ex, vi, emacs, sed, awk,
cat > file, whatever we have put on the system. We wouldn't try to
build a command file out of an 'ls > file' with anything but ed or vi
(maybe awk or sed, same thing basically) we wouldn't try to write an
editor based mail interface in anything but an emacs.  We also use
probably a half-dozen programming languages and a dozen or more
utilities regularly in the course of our work, others when called for,
without pausing to ponder whether we find m4 more pleasant than yacc
(unless we have the urge to rewrite one or the other) For changing a
few chars in a file it takes us about 1/10th of a second to decide
whether to type in 'emacs foo' or 'ed foo' or 'vi foo' or whatever
will do the job the fastest.

Emacs has its advantages in being a completely programmable editor, vi
has its advantage in line-oriented regular expression substitution
that just doesn't seem to fit into emacs well as simple commands (I
know, you can do ANYTHING in emacs, but when I want to say something
like '1,$s/.*/mv & \/usr\/lib\/new\/&/' I find vi/ed trivial and emacs
opaque.) We have also noted that ed and vi load much faster than
emacs.  On my workstation I use emacs a lot, on the student 750
running at a load of 25 or more I always use ed or vi.

We consider changing editors in the middle of an edit to just be
another editor command (^X^S M-X Kill-Buffer ^Z ed foo 1,$s/^/>/ w q
%emacs ^X^F foo). That is why we made it so easy to do.

Besides, for us vi IS a programmable editor. We have the sources :-)

Most importantly, we don't waste our time arguing over whether it is
better to do all carpentry with either a hammer or a screwdriver, we
make sure both are in our toolbox if we can help it. If not we
recognize it's an inferior situation but will get the job done anyhow
with little trouble.

But what about the users who will only learn one editor? Wait a
minute, I thought this was UNIX-WIZARDS?!

	-Barry Shein, Boston University

ken@rochester.ARPA (Comfy chair) (10/14/86)

|Most importantly, we don't waste our time arguing over whether it is
|better to do all carpentry with either a hammer or a screwdriver, we
|make sure both are in our toolbox if we can help it.

I am reminded of people who spend 30 seconds trying to get a csh
substitute to work when they could have retyped it faster.

What's the connection? As Barry says, if you are any good you will
learn all the tricks you can. But you should also be smart enough to
recognize when a solution is inadequate and seek new ones. The
discussion has simply degenerated to a "my editor can beat up your
editor" argument.

Neato reversing tricks are nice, but please followup to net.lang or
maybe net.religion. How about something completely different now?

	Yawn, Ken

mwm@cuuxb.UUCP (Marc W. Mengel) (10/14/86)

In article <21557@rochester.ARPA> ken@rochester.UUCP (Comfy chair) writes:
>|Most importantly, we don't waste our time arguing over whether it is
>|better to do all carpentry with either a hammer or a screwdriver, we
>|make sure both are in our toolbox if we can help it.

	I hereby publicly apologise for feeding the editor flames. It
	was a rash action in a moment of weakness, and won't happen
	again.  :-) Thanks to the people who pointed out ^U to give a
	count to EMACS commands, etc.   

-- 
 Marc Mengel
 ...!ihnp4!cuuxb!mwm

tim@ism780c.UUCP (10/22/86)

> Unfortunately, I can't use Gnu EMACS because it's too big to run
> on an Intel pseudo-computer.

TECO can do anything, and is not so bloated that you need a few giga-bytes
to make it work.  Geez, can't anyone write small programs anymore?
-- 
member, all HASA divisions              POELOD  ECBOMB
                                        --------------
                                               ^-- Secret Satanic Message

Tim Smith       USENET: sdcrdcf!ism780c!tim   Compuserve: 72257,3706
                Delphi or GEnie: mnementh