home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / unix / question / 15830 < prev    next >
Encoding:
Internet Message Format  |  1993-01-21  |  3.1 KB

  1. Path: sparky!uunet!ferkel.ucsb.edu!ucsbcsl!engrhub!harley
  2. From: harley@engrhub.ucsb.edu (Harley Hahn,,,HAHN,personal)
  3. Newsgroups: comp.unix.questions
  4. Subject: Re: So what _is_ so good about vi?
  5. Message-ID: <7448@ucsbcsl.ucsb.edu>
  6. Date: 22 Jan 93 03:51:50 GMT
  7. References: <1jcoq7INN5eg@zikzak.apana.org.au> <1993Jan18.223845.10225@ucsu.Colorado.EDU> <ln_smr.727524292@pki-nbg.philips.de>
  8. Sender: root@ucsbcsl.ucsb.edu
  9. Lines: 82
  10.  
  11. In article <ln_smr.727524292@pki-nbg.philips.de> ln_smr@pki-nbg.philips.de writes:
  12. >radinsky@spot.Colorado.EDU (Wayne Radinsky) writes:
  13. >>PS Anyone know why "s" is used as an equivalent for "c "?
  14. >s = substitute character (same as cl (change letter))
  15. >S = substitute line (same as cc (change line)).
  16.  
  17. True, but we can be a little more precise.
  18. "s" is not really a substitute for "c".
  19.  
  20. Like some other vi commands, "c" is followed by a cursor
  21. move command.  It indicates that you want to substitute an
  22. arbitrary number of characters for the data that is between
  23. the current position and wherever the cursor move oepration
  24. would move the cursor.
  25.  
  26. For example:
  27.  
  28. cw      --> substitute characters to the next 'end of word'
  29. c)      --> substitute characters to the next 'end of sentence'
  30. c}      --> substitute characters to the next 'end of paragraph'
  31.  
  32. Of course, you can use more complex cursor move commands:
  33.  
  34. c4w     --> substitute characters to the fourth next 'end of word'
  35.  
  36. (Notice the beauty of vi, all the cursor movement commands
  37. that you memorize are used in so many ways.)
  38.  
  39. The "s" command, on the other hand does not take a following
  40. cursor movement command.  By definition, "s" replaces only
  41. a single character.  
  42.  
  43. Now, the convention is that for commands that can be followed by
  44. a cursor movement command (such as "c", "d", "y"),
  45. a double-letter command acts on the entire current line.
  46.  
  47. Thus, "cc" changes the entire current line.
  48. "dd" deletes the entire current line.
  49. "yy" yanks the entire current line to the unnamed buffer.
  50.  
  51. Commands that cannot be followed by a cursor movement command,
  52. such as "s", do not have double-letter cousins.
  53. Thus, there is no "ss" command.
  54.  
  55. (This only makes sense because commands like "s" go into
  56. input mode immediately and the second "s" would be taken
  57. as input.)
  58.  
  59. Finally, each of these commands has a capitalized counterpart:
  60. "C", "D", "Y" and "S".
  61.  
  62. The convention is that this counterpart performs the same operation
  63. on all or part of the current line, WHICHEVER WOULD BE
  64. THE MOST USEFUL.
  65.  
  66. Thus, "C" and "D" act from the cursor position
  67. to the end of the current line.
  68.  
  69. "Y" and "S" act on the entire current line, regardless of
  70. the cursor position.
  71.  
  72. Thus, "S" is the same as "cc".
  73.  
  74. ----------
  75.  
  76. See why vi is so wonderful:  It all makes sense :-)
  77.  
  78. The rules, as you can see, are complex and most people
  79. don't bother to learn them. But as you practice,
  80. your mind will learn the rules without you
  81. ever consciously knowing what they are.
  82. (Sort of like life...)
  83.  
  84. Thus, after awhile, you will find youself zipping along
  85. using rules you don't really need to understand.
  86.  
  87. |-------------------------------------------|
  88. | vi is difficult to learn but easy to use. |
  89. |-------------------------------------------|
  90.  
  91. -- Harley Hahn
  92.  
  93.