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
List of Tasks
- Download (save link/page )
the file vi_practice file
to your home directory.
this file in the vim (vi) editor.
- (1 point) Practice
cursor movement commands:
(1 point) Practice
the cursor right and left one character, and down and up one line
the cursor 10 characters to the right, then 5 lines down by pressing only
the cursor to the beginning of a line, then go word by word across the
the cursor to the beginning and the end of the line with single character
the cursor to line 20 without counting the lines, then go up one page
(1 point) Practice
search and replace commands:
the first line of the file (there is a delete-line command)
the first 2 characters of what is now line 7
- Add words
"AND DYNAMICS" right after line 15, on the same line.
lines 19 and 20
the file and quit vi, which returns you to the shell prompt.
sure you did everything correctly by typing the command
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"
string "understor". Where did this one come from?
- Now find
every occurence of "And" and replace it with "But"
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
diff -y vi_practice vi_practice_edited
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 ...
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?
each file and quit vi.
When you have
finished editing the PDB and the answer files, call your instructor.