Ben A L Jemmett wrote:

(in response to:)
> > Okay, once more for us idiots, straight and to the
> > point.  does another editor come with all the distros,
> > if so, what string of text makes it come up?
> >

: I have inserted some comments, and a final note at the
: end of Ben's (rather good) explanation.

<large snip>
> Knowing vi (or at least the basics of vi) is something
> that'll come in handy again and again and again.  As
> it's on nearly every system, knowing the following is
> useful:
>
> INVOCATION: vi <filename> (e.g. vi .bashrc,
> vi /etc/sendmail.cf, vi *.txt) - will start up vi
> (or a vi-clone in true vi mode) with the first file
> specified on screen.
> CURSOR MOVEMENT: Usually the cursor keys are functional.
> I think hjkl will move the cursor left/up/down/right
: yes, h j k l are the basic motion keys

> if the cursors are not mapped.  PgUp and PgDn often
> work too.
: Ctrl+F = page (F)orward, Ctrl+B = page (B)ackward


> EDITING: Hit ':i' to switch to insert mode, and type.
: Actually, I just press 'i' to (i)nsert (before the
: current letter, 'a' to enter text (a)fter current
: position (by the way, the command letters are Case
: Sensitive -- 'A' appends at end of current line, while
: 'a' appends after current letter.

: Also, don't forget the 'x' (delete current character)
: command, or the 'dd' (delete current line) or the 'D'
: (delete end of line) commands.

> When done, hit Escape a couple of times
> (once should be enough, but I always hit it two or
> three times just to make sure...).
: Agreed.

> SAVING/CLOSING/EXITING: To save changes, hit ':w'.
> (If the file was read-only, ':w!' will force an
> overwrite, but that's usually Bad VooDoo).
: Also, ':q!' will (q)uit from edit and lose changes.

> To close the current file and move onto the next
> (if you specified multiple files on the command line),
> use ':n'.
: (not for beginners, try some single-file edits first.

> If you haven't saved changes you see an error -
> use ':n!' to discard the changes, or save and then
> move onto the next file.  To finish with vi, use ':q'.
> If you're editing the last or only file specified and
> you haven't made unsaved changes, you're outta there.
> To force an exit if you either want to discard changes
> or want to ignore the rest of the files, use ':q!'.
: Uhhh ... yeah, what he said.

> SEARCHING FOR TEXT: This is '/searchstring/' and
> then '/' to find again. Searchstring can also be a
> regexp.  Ignore regexps for now.
: but learn them -- they (regular expressions) are
: pure gold when you know how to use them.
: -- oh, the 'n' command will search for (n)ext --

>  To search and replace, 's/original/replacement/'.
> Again, regexps possible.
>
> Regards,
> Ben A L Jemmett
: Thank you, Ben.

Also, for those of us who have no exposure to line
editors, but who have only had full-screen editors
to work with, please note:

Unlike most DOS/Windows editors, (in which the default
mode is "typing text" and special functions like search,
delete, open, close, and navigation require the use of
special keys), the VI family of editors has distinct
"modes" -- "command" and "text entry" modes.

When you start, you're in command mode.  In an empty
document, your first command will be 'i' or 'a' to
begin text entry.  Note that <Tab> characters are
taken literally.  They are entered as a single byte,
but displayed as one or more empty spaces.

In command mode, the normal letter and number keys
become mostly one-stroke commands, enhanced by numeric
prefixes ('k' = 'up one line' while '5k' = 'up 5 lines')
with more involved command combos beginning with ':'
(like :s/Smith/Smythe/ = substitute Smythe for Smith).

VI is not particularly glamorous but it is present on
just about every flavor of UNIX there is and it has
enough power to handle most text jobs.  Used with a
text formatter, you can even do word processing with
it.
(No, I'm not advocating that.)

And finally, having glazed everyone's eyes over,
you can get the rest of the story with the command
"man vi" on most boxes.

Regards,
Garry Hamilton

To unsubscribe from SURVPC send a message to [EMAIL PROTECTED] with 
unsubscribe SURVPC in the body of the message.
Also, trim this footer from any quoted replies.

Reply via email to