home *** CD-ROM | disk | FTP | other *** search
/ Nebula / nebula.bin / Documents / Others / viCourse+ / BeginersGuide.txt < prev    next >
Internet Message Format  |  1992-12-20  |  6KB

  1. From: werner@aecom.UUCP (Craig Werner)
  2. Subject: VI Beginner's Guide (by request)
  3. Date: Mon, 28-Oct-85 23:52:14 EST
  4.  
  5.     I recently posted a WS guide here, and in the posting I mentioned I
  6. also had one for 'vi'.  By the request of several, here it is.
  7.     Please note that I wrote this while I was teaching a beginner course
  8. at Harvard several years ago, so the whole thing is applicable EXCEPT the
  9. original setup information.
  10.     This is local to site. Currently, I use a TERM=whatever, followed by
  11. export TERM to take care of the setup. This is more flexible than the .exrc.
  12.  
  13.  
  14. This list is not complete, but I like to think that it is comprehensive. 
  15. Except for typos, my only additions in three years have been the following four:
  16.  
  17. Buffers - they used to be mentioned in "Things I'm telling you about."  Now 
  18.     there is a short description after yy/dd in the editing section. 
  19. #1,#2 w name - writing excerpts
  20. :r!command  - reading command output directly to current file. 
  21.  
  22.     If you detect any egregious ommisions let me know.
  23.  
  24.                 Craig Werner
  25.                 1935-14E Eastchester Rd.
  26.                 Bronx NY 10461
  27.                 (werner@aecom.UUCP)
  28.  
  29. ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  30. A Naive Introduction to vi (the visual editor)
  31.                     c. 1982 by Craig Werner, 
  32.                     Harvard Core Computer Requirement
  33.                     (revised 1984,1985)
  34.  
  35. To enter vi, unless this is your first time, just type
  36.  
  37. & vi filename <return> directly to the shell
  38.              where "filename" can be any name you want
  39.  
  40. If this is your first time, then before you do that, type
  41.     & cat > .exrc  <return>  (the cursor will go down one line)
  42.     set term=t1061 <return>  (with no shell prompt, &)
  43.            ^-- or whatever terminal (vt100 h19 etc) you are on.
  44.     <control-d>              (the control key is next to the shift key)
  45.  
  46. ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  47. Cursor Movement Commands
  48.  
  49.                      1G
  50.                      (k)
  51.                       -
  52.                       ^
  53.                       |
  54.                       |
  55.           0 b (h) backspace <--------here---------> space (l) w $
  56.                       #G
  57.                       |
  58.                       |
  59.                      \|/
  60.                     ENTER
  61.                      (j)
  62.                       G
  63. where
  64. backspace, space, - , and ENTER go one move in their respective direction
  65.     (as do h,l,k, and j, which are all next to each other in the right hand)
  66. w and b move one word away
  67. 0 (zero), $, 1G, and G go to the beginning or end in that particular direction
  68. #G (where # is a number)  takes you to the line with that number
  69.     (--> to find out what number line you are on, type <control>-g)
  70.  
  71. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  72. Insert Commands   (This is where you do all your writing)
  73.  
  74. i  insert
  75. a  append (just like insert except starts one character later)
  76. o  open   (makes an empty line after the current one, and insert)
  77.       (just like "a <ENTER>")
  78. A  append to end of line 
  79.       (just like  $ a)
  80.  
  81. NOTES:
  82.     1. All insert commands put one in the insert mode. To leave the
  83.        insert mode to do other commands, one must hit <ESCAPE>.
  84.     2. While in the insert mode, one must hit <Rubout> and not
  85.        <backspace> to back up.
  86.  
  87. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  88. Editing Commands
  89.  
  90. x remove a character (x it out)
  91. r replace a character
  92. s substitute a character. This does an x, then puts you in the insert mode
  93.  
  94. NOTE: x and s (but not r - a rare exception) will take a number in front of
  95.     them. For instance, 5x will nuke 5 letters.
  96.  
  97. J - join two lines (remove a carriage return and concatenate)
  98.  
  99. d delete, which is used as
  100. dw  - delete word
  101. dd  - delete an entire line
  102.  
  103. c change, similarly
  104. cw  - change word
  105. cc  - change line
  106.     (c first deletes, but not on the screen, and then puts you in the
  107.      insert mode)
  108.  
  109. yw/yy - yank lines into a buffer, where you can use
  110. p     - to put them somewhere else in a file.
  111.  
  112. NOTE: the yanked lines can be put as often as one likes, which is a good way
  113.     to repeat things.
  114.       Also, deleted lines can be put as well, so dd is the same as yy,dd
  115. NOTE 2: There is only one default buffer. To move two things, or to yank and 
  116.     put with other work in between, you can save to named buffers. To do
  117.     this type ' "a command', where  the double quote is typed, the 'a' can 
  118.     be replaced by any letter a-z, and the command is yy/dd, etc.
  119.     The text so selected can then be put by ' "a p '.
  120. ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  121. Search Commands
  122. / pattern - searches for a pattern in the text after the cursor
  123. ? pattern -     "     "  "   "     "   "   "   before "    "
  124. n next    - keeps searching in the same direction
  125. N  "      -  "       "      "   " opposite direction
  126.  
  127. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  128. Two Special Commands
  129.  
  130. u undo - This is IMPORTANT. It undoes the last thing you did, in case you
  131.      really goof.
  132. . repeat (That's a period) repeats the last editing or insert command, great
  133.       for use along with the search commands to correct a mistake
  134.       occuring everywhere, etc...
  135.  
  136. ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  137. Things I'm not telling you - ask for more info
  138.  
  139. Other commands (including capital letters which are sometime significant)
  140.  
  141. ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  142. Colon Commands
  143.  
  144. :w         write the file and save the changes
  145. :w name         same, but the changes go into a file with the new name
  146. :#1,#2 w name   write only the lines #1 to #2 to the file (for excerpting)
  147. :q         quit, leave the editor
  148. :q!         quit, leave the editor - with extreme prejudice
  149. :wq         write and quit at the same time
  150. :r         read in a file to the point where the cursor is
  151.             (good for combining files)
  152. :!shell-command execute a shell-command (no space between ! and name) without
  153.     ever leaving the editor.
  154. :r!shell-command  (execute as above, but bring output into document.)
  155. :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  156.  
  157. -- 
  158.  
  159.                 Craig Werner
  160.                 !philabs!aecom!werner
  161.                "Why is it that half the calories is twice the price?"
  162. d ong oone ng oone ng oone ng oone ng oone ng oone ng oone ng oone ng oone ng oone ng oone ng oone ng oone ng oone ng oone ng oone ng oone ng oone ng oone ng oone ng oone ng oone ng oone ng oone ng oone ng oone ng oone ng oone ng oone ng oone ng oone ng oone ng o