home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ferkel.ucsb.edu!ucsbcsl!engrhub!harley
- From: harley@engrhub.ucsb.edu (Harley Hahn,,,HAHN,personal)
- Newsgroups: comp.unix.questions
- Subject: Re: So what _is_ so good about vi?
- Message-ID: <7448@ucsbcsl.ucsb.edu>
- Date: 22 Jan 93 03:51:50 GMT
- References: <1jcoq7INN5eg@zikzak.apana.org.au> <1993Jan18.223845.10225@ucsu.Colorado.EDU> <ln_smr.727524292@pki-nbg.philips.de>
- Sender: root@ucsbcsl.ucsb.edu
- Lines: 82
-
- In article <ln_smr.727524292@pki-nbg.philips.de> ln_smr@pki-nbg.philips.de writes:
- >radinsky@spot.Colorado.EDU (Wayne Radinsky) writes:
- >>PS Anyone know why "s" is used as an equivalent for "c "?
- >s = substitute character (same as cl (change letter))
- >S = substitute line (same as cc (change line)).
-
- True, but we can be a little more precise.
- "s" is not really a substitute for "c".
-
- Like some other vi commands, "c" is followed by a cursor
- move command. It indicates that you want to substitute an
- arbitrary number of characters for the data that is between
- the current position and wherever the cursor move oepration
- would move the cursor.
-
- For example:
-
- cw --> substitute characters to the next 'end of word'
- c) --> substitute characters to the next 'end of sentence'
- c} --> substitute characters to the next 'end of paragraph'
-
- Of course, you can use more complex cursor move commands:
-
- c4w --> substitute characters to the fourth next 'end of word'
-
- (Notice the beauty of vi, all the cursor movement commands
- that you memorize are used in so many ways.)
-
- The "s" command, on the other hand does not take a following
- cursor movement command. By definition, "s" replaces only
- a single character.
-
- Now, the convention is that for commands that can be followed by
- a cursor movement command (such as "c", "d", "y"),
- a double-letter command acts on the entire current line.
-
- Thus, "cc" changes the entire current line.
- "dd" deletes the entire current line.
- "yy" yanks the entire current line to the unnamed buffer.
-
- Commands that cannot be followed by a cursor movement command,
- such as "s", do not have double-letter cousins.
- Thus, there is no "ss" command.
-
- (This only makes sense because commands like "s" go into
- input mode immediately and the second "s" would be taken
- as input.)
-
- Finally, each of these commands has a capitalized counterpart:
- "C", "D", "Y" and "S".
-
- The convention is that this counterpart performs the same operation
- on all or part of the current line, WHICHEVER WOULD BE
- THE MOST USEFUL.
-
- Thus, "C" and "D" act from the cursor position
- to the end of the current line.
-
- "Y" and "S" act on the entire current line, regardless of
- the cursor position.
-
- Thus, "S" is the same as "cc".
-
- ----------
-
- See why vi is so wonderful: It all makes sense :-)
-
- The rules, as you can see, are complex and most people
- don't bother to learn them. But as you practice,
- your mind will learn the rules without you
- ever consciously knowing what they are.
- (Sort of like life...)
-
- Thus, after awhile, you will find youself zipping along
- using rules you don't really need to understand.
-
- |-------------------------------------------|
- | vi is difficult to learn but easy to use. |
- |-------------------------------------------|
-
- -- Harley Hahn
-
-