No Next Item No Next Conference Can't Favor Can't Forget Item List Conference Home Entrance    Help
View Responses


Grex Info Item 8: Where to find an intro to "vi", a Unix text editor
Entered by popcorn on Tue Nov 10 04:33:32 UTC 1992:

This item text has been erased.

28 responses total.



#1 of 28 by popcorn on Tue Nov 10 04:39:49 1992:

This response has been erased.



#2 of 28 by remmers on Tue Nov 10 12:23:25 1992:

Nice writeup.

One correction concerning something you say at the end -- "man vi" does
*not* give information on vi commands.


#3 of 28 by popcorn on Wed Nov 11 04:31:17 1992:

This response has been erased.



#4 of 28 by tsty on Thu Nov 12 05:09:00 1992:

wow -that's a chock-full chunk! 


#5 of 28 by wh on Tue Mar 14 18:41:23 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.


#6 of 28 by popcorn on Tue Mar 14 19:49:30 1995:

This response has been erased.



#7 of 28 by popcorn on Tue Mar 14 19:49:39 1995:

This response has been erased.



#8 of 28 by nephi on Tue Mar 14 21:40:38 1995:

*z*cat?  What does zcat do?


#9 of 28 by rcurl on Wed Mar 15 07:17:24 1995:

It reads a compressed file.


#10 of 28 by nephi on Wed Mar 15 11:40:51 1995:

Thanks.
,


#11 of 28 by davel on Sat Mar 18 03:12:57 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.)


#12 of 28 by albaugh on Thu Jan 25 17:01:32 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.


#13 of 28 by davel on Thu Jan 25 18:54:55 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.


#14 of 28 by remmers on Fri Jan 26 11:45:39 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".


#15 of 28 by popcorn on Fri Jan 26 13:49:16 1996:

This response has been erased.



#16 of 28 by davel on Fri Jan 26 19:50:58 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.


#17 of 28 by mdw on Sun Jan 28 04:15:36 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


#18 of 28 by popcorn on Wed Jan 31 06:42:32 1996:

This response has been erased.



#19 of 28 by remmers on Wed Jan 31 14:05:11 1996:

Almost as convenient as dragging a mouse! :)


#20 of 28 by wh on Wed Aug 28 17:29:30 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.



#21 of 28 by popcorn on Thu Aug 29 04:32:53 1996:

This response has been erased.



#22 of 28 by nestene on Thu Aug 29 06:44:40 1996:

:se nu


#23 of 28 by davel on Thu Aug 29 14:01:32 1996:

(Which is short for "set numbers".  But yes, that's the way.)


#24 of 28 by remmers on Thu Aug 29 17:56:43 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.


#25 of 28 by kentn on Thu Sep 12 03:43:25 1996:

A couple of places to look for vi-related information are:

   http://www.cs.vu.nl/~tmgil/vi.html (The VI Lover's Home Page)
   and 
   ftp://alf.uib.no:/pub/vi/ (if you ftp directly there, just
   cd to the vi directory--no 'pub')
 
Apparently, ftp.uwp.edu or ftp.uu.net are supposed to have vi information
but I either had a difficult time connecting or the site is being
remodeled so I couldn't find what I was looking for.  (uwp allows
web access at http://archive.uwp.edu, although I did not see any vi
documentation there when I looked).

The VI Lover's page, btw, has links to a lot of vi information and would
probably be my first Web choice (although you might also try Yahoo! under
Computers/Software/Editors/vi).

Okay, I got through to ftp.uwp.edu (/pub/vi) and it looks like alf.uib.no,
which is to say, there is a fair amount of information there as well
as programs for various types of computers. (Actually, it seems uwp is
a mirror of alf.uib.no, so they are the same).  I grabbed a few files
while I was there; you probably will, too, if you are interested in vi.


#26 of 28 by myindia on Mon Oct 18 10:09:08 1999:

To get line number listing of a document in vi , add following lines to your
.cshrc file :
setenv EXINIT 'se nu smd'
But I am not sure how to get this line numbered listing while printing this
file to printer.If anybody knows  , then please let me know.


#27 of 28 by mdw on Wed Oct 20 01:36:49 1999:

I don't think that's particularly a vi question, but variations on "cat
-n file | lpr" or "egrep -n '^' file | lp" could work.

Of course, ':set smd' doesn't have anything to do with line numbers.
It's possible to type ':set nu' at any time to turn line numbering on,
and ':set nonu' to turn it off again.  I prefer to run with it it off
nearly all of the time, as the numbers get in the way, and in some
versions of vi, can cause display pecularities.


#28 of 28 by myindia on Sun Dec 26 10:12:17 1999:

Thanks mdw,

I am happy to know this. It was only recently that experimented with
set nu etc, and learned most of vi features, when in my local server
our administrator refused to install pico.

Response not possible - You must register and login before posting.

No Next Item No Next Conference Can't Favor Can't Forget Item List Conference Home Entrance    Help

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