Lab meeting: Learning the vim editor
If you arrive
before lab begins, feel free to log on, work on
assignments, or begin the lab work. 
This week we will be using the vim editor in addition to the commands we have
already learned. On most modern unix machines vim and vi are the same thing. 
 If you have questions about vim, you can look it up in your book or 
follow the links from the class site. If you
cannot remember what a command does, try 'man <command>'.  Also,
there is a tutorial on
fundamental and advanced vi at the University of Washington that you can
reference. 
List of Tasks
 - Download  (save link/page )
     the file   vi_practice  file 
     to your home directory.
- Open
     this file in the vim (vi) editor.
-  (1 point) Practice
     cursor movement commands: 
  - move
      the cursor right and left one character, and down and up one line
- move
      the cursor 10 characters to the right, then 5 lines down by pressing only
      5 keys
- move
      the cursor to the beginning of a line, then go word by word across the
      line
- move
      the cursor to the beginning and the end of the line with single character
      commands
- move
      the cursor to line 20 without counting the lines, then go up one page
      (screen)
-  (1 point) Practice
     editing commands:
  - delete
      the first line of the file (there is a delete-line command)
- delete
      the first 2 characters of what is now line 7
- Add words 
       "AND DYNAMICS" right after line 15, on the same line. 
- join
      lines 19 and 20
-  (1 point) Practice
     search and replace commands:
  - go
      to the beginning of the file and find the next occurrence of the word "and".
      Replace it with "OR".
- 
      Replace all occurences of string "and" with "or" 
-  Find 
   string "understor". Where did this one come from? 
-  Now find 
     every occurence of "And" and replace it with "But" 
     
- Save
     the file and quit vi, which returns you to the shell prompt.
- Download 
        
      vi_practice_edited   Make
     sure you did everything correctly by typing the command 
 diff vi_practice vi_practice_edited
 This command looks for any differences in the contents of the two
     files. If you get no output from this command, you've done everything
     correctly.  You can also compare the two files next to each other by
     typing
 diff -y vi_practice vi_practice_edited
- Now
     we're going to edit another text file - this time a PDB file that describes a real protein. Right
     click on this link and choose "Save link
     as... Or Save to disk...". Save the file in your home directory. Now open another unix shell and 
       create a file named 
     lab2_my_answers in your home directory. You will put your answers to questions Q1, Q2 and Q3 (below) in it, 
        each answer on its own line. Eaxmple: Q1:    Bla-bla-bla ... 
-  Open
     the file in the vi editor, and make the following changes:
  -  (1 point) Change
      the date on the first line to today's date 
-  (2 points ) Delete 
      all lines from 130 to 230.  
      
-  (1 point ) Replace 
      every string "ATOM" with "ELEMENT" 
-  
     (1 point ) Q1:  How many total lines are in your file now? 
-  
       ( 3 points ) Decrease the spacing between string "ELEMENT" and the number next to it by 
       exactly two spaces, for EVERY LINE in the file. 
-  
      (1 point each ) Q2: What animal ( ORGANISM_COMMON  )  does this protein come from?  Q3: What 
      is the scientific name for this animal?  
- Save
     each  file and quit vi. 
Assessment
When you have
finished editing the PDB  and the answer files, call your instructor.