You are not logged in. Login Now
 0-24   25-28         
 
Author Message
popcorn
Where to find an intro to "vi", a Unix text editor Mark Unseen   Nov 10 04:33 UTC 1992

This item has been erased.

28 responses total.
popcorn
response 1 of 28: Mark Unseen   Nov 10 04:39 UTC 1992

This response has been erased.

remmers
response 2 of 28: Mark Unseen   Nov 10 12:23 UTC 1992

Nice writeup.

One correction concerning something you say at the end -- "man vi" does
*not* give information on vi commands.
popcorn
response 3 of 28: Mark Unseen   Nov 11 04:31 UTC 1992

This response has been erased.

tsty
response 4 of 28: Mark Unseen   Nov 12 05:09 UTC 1992

wow -that's a chock-full chunk! 
wh
response 5 of 28: Mark Unseen   Mar 14 18:41 UTC 1995

Where do we have this listed? I have a printout and still use it.
It's good enough to keep. New users might like to see it.
popcorn
response 6 of 28: Mark Unseen   Mar 14 19:49 UTC 1995

This response has been erased.

popcorn
response 7 of 28: Mark Unseen   Mar 14 19:49 UTC 1995

This response has been erased.

nephi
response 8 of 28: Mark Unseen   Mar 14 21:40 UTC 1995

*z*cat?  What does zcat do?
rcurl
response 9 of 28: Mark Unseen   Mar 15 07:17 UTC 1995

It reads a compressed file.
nephi
response 10 of 28: Mark Unseen   Mar 15 11:40 UTC 1995

Thanks.
,
davel
response 11 of 28: Mark Unseen   Mar 18 03:12 UTC 1995

(Various standard & semi-standard Unix compression utilities use file
extensions of .Z and .z (and now .gz) by default.  Hence zcat,
zmore, etc., etc.)
albaugh
response 12 of 28: Mark Unseen   Jan 25 17:01 UTC 1996

Could someone please supply the vi syntax for doing a replace?  Specifically,
I want to replace each occurrence of ">" at the beginning of a line with
the null string.
davel
response 13 of 28: Mark Unseen   Jan 25 18:54 UTC 1996

This will do it for your whole file:           :%s/^>//g
This will do it everywhere in lines 5-10:      :5,10s/^>//g

If I say that ":" gets you into last-line mode, that "s" is the command
("substitute"), that "/" is a separator, that "^" matches beginning of
string (in this case of line), and that "g" is for "global" and says
to do them all, I expect that you can figure out how to extend this
to other replacements, right?     8-{)]

And if I say that I'm not sure what the alternatives to "g" are (my
experience being that including & omitting it seem to work the
same), I'm sure that someone will explain.

You can also add to the end a "c" (with or without the "g"), and you
will be prompted for confirmation for each replacement.
remmers
response 14 of 28: Mark Unseen   Jan 26 11:45 UTC 1996

The "g" causes replacement of all occurrences on a line of the
replacement pattern; omit the "g" and it will replace only the
first occurrence on each line. Since Kevin wants to replace only
the occurrences of ">" at beginnings of lines, he probably doesn't
want to include the "g".
popcorn
response 15 of 28: Mark Unseen   Jan 26 13:49 UTC 1996

This response has been erased.

davel
response 16 of 28: Mark Unseen   Jan 26 19:50 UTC 1996

Thanks, John.  Whatever I'd read, way back when, suggested (to my mind,
anyway) that omitting the "g" would lead to replacement of only the first
occurrence - which plainly didn't seem to happen.  Either the "in each
line" was omitted, or I missed it.  (I think all the examples on that
point involved an address range of a single line.  <sigh>)  That should
be very useful, now that you've explained how it *does* work.

I also would like to know how to use marks in address-range things.
mdw
response 17 of 28: Mark Unseen   Jan 28 04:15 UTC 1996

Marks come from ed.  In ed, you can mark a line by saying "kX", (where X
is a letter a-z) and you can then use marks in line ranges in place of
numbers.

So, if you wanted to capitalize all occurences of "the" from lines 3-6,
you could say:
        3ka
        6kb
        'a,'bs/the/THE/g

You can use marks just the same way in command mode in vi (which is of
course just "ex").  So, ":3ka"<return> will indeed mark line 3.  But you
can also mark lines directly in visual command mode, with m - "ma" will
mark a mark on the current line, just like ":ka"<return>.  You can go to
a mark with 'X in visual mode - so "'a" will go to mark a.  "''"p is
kind of handy - it will go back to the last place you came from - so you
can search for a string, then jump back to where you were.

I most commonly use marks for moving and shifting text blocks.  In
visual mode, I can mark the start with "ma", go to the end of what I
want to shift, and say ">'a" to shift from the current line to the line
marked a.  Or, if I want to move stuff, I can mark where I want to move
stuff to with "mc", then the start & end with "ma" & "mb", and then say
":'a,'bm'c"<return>

Regarding g & c.  Ed doesn't support c.  Both ex & ed support p there.
p will print out the last line that was changed - which saves
typing p on a separate line.  ex has a "set autoprint" which defaults
on & acts as if a 'p' were always supplied.  Without g, ex will
indeed only change one occurrence per line, so if the file reads:
        aruba
        mta
        robh
and you say 1,$s;a;b;
you will get:
        bruba
        mtb
        robh
popcorn
response 18 of 28: Mark Unseen   Jan 31 06:42 UTC 1996

This response has been erased.

remmers
response 19 of 28: Mark Unseen   Jan 31 14:05 UTC 1996

Almost as convenient as dragging a mouse! :)
wh
response 20 of 28: Mark Unseen   Aug 28 17:29 UTC 1996

How can we list by line numbers in vi? Also, since we don't have
a  man page for vi, is there somewhere to ftp one for grex, or
download something similar to a manual page.

popcorn
response 21 of 28: Mark Unseen   Aug 29 04:32 UTC 1996

This response has been erased.

nestene
response 22 of 28: Mark Unseen   Aug 29 06:44 UTC 1996

:se nu
davel
response 23 of 28: Mark Unseen   Aug 29 14:01 UTC 1996

(Which is short for "set numbers".  But yes, that's the way.)
remmers
response 24 of 28: Mark Unseen   Aug 29 17:56 UTC 1996

There's a vi ftp archive where one can download tons of
documentation. I don't have the address handy but will try to
remember to look it up and post it here.
 0-24   25-28         
Response Not Possible: You are Not Logged In
 

- Backtalk version 1.3.30 - Copyright 1996-2006, Jan Wolter and Steve Weiss