vim (2)Read everything before doing anything!
First: if you don’t have the vim cheat sheet,
download it now (PDF format).
Parts one and two are for your practice; I could look at the files afterward, but I would have no idea if you had done the correct commands! That doesn’t mean you should just skip those parts–the practice will help you for the questions at the end.
Do the tutorial on pages 153 through 174.
Do the following steps, using the files preamble.txt and lincoln.txt from the previous assignment:
Type vim preamble.txt to start editing the file.
Move the cursor to the last letter o in the word Posteriors in line 5, and delete the remainder of the word by typing dw.
Now type i to enter insert mode, add ty and press ESC to finish correcting the word to Posterity.
Move the cursor to the beginning of line 2, and press R to enter replace mode. Type more and press ESC.
Move the cursor to the r in prefect and then press xp to swap the bad characters. (The x deletes the character, and p pastes it in after the cursor position.)
Change all occurrences of united to United with this command:
:1,$s/united/United/g
Remove all occurrences of Tranquility at the beginning of a line with this command:
:1,$s/^Tranquility//
On all lines that contain the word of, change states to States with this command:
:g/of/s/states/States/
Write the file back to disk by typing
:w [Note: you are NOT exiting vi!]
Type :vi lincoln.txt to start editing that file.
With one command, correct all occurrences of teh to the.
Move to the line starting Fourscore and seven years ago
Copy the next three lines plus the following blank line into the general-purpose buffer by typing 4Y (make sure you use a capital Y).
Move up to the line starting Now we are engaged in a great and press P to paste the text before the text.
Move back down to the lines you copied, and delete them with one command.
Type :wq to write the file back to disk and quit
vim.
Answer the following questions. Please use a plain text file rather than a word processor. Do not send me a .doc file! Name the file in the form lastname_firstname_vim2.txt Then upload the file to Moodle.
What commands would you use in vim to: