Unix - Hour 10 An Introduction to the 'vi' Editor 10.1.1) typing vi the screen cleared and the first character of each line is a ~. internet% vi Typing : it moved the cursor to the last line, typing q followed by enter brought back the shell prompt. ~ ~ :q internet% 10.1.2) Set the type of terminal to be understood by UNIX. internet% setenv TERM vt100 internet% 10.1.3) Created a file called demo with the content of the command 'ls -l' internet% ls -l > demo internet% vi demo total 46 drwxr-xr-x 3 spantaro students 512 Jun 3 16:14 OWL -rwx------ 1 spantaro students 1373 MMay 22 23:42 README -rwx------ 1 spantaro students 1417 JJun 6 17:09 README.2 -rw-r--r-- 1 spantaro students 1373 MMay 30 17:08 READMES -rw-r--r-- 1 spantaro students 0 JJun 2 18:32 TEST -rwxr-x.... 10.2.1) File demo was opend and the cursor was placed in the first character of it. In this case letter 't' of word 'total'. 10.2.2) Typing 'h' to move left made unix beep. Typing 'k' to move up made unix beep. Typing 'j' to move down made cursor go one position down. Typing 'l' to move right made unix move right. 10.2.3) Moved around the file with keys h,j,k,l moving with enter takes you down to the first character of each line. backspace did not work. 10.2.4) The 0 (zero) moved to the beginning of the line. The $ moved to the end of the line. 10.2.5) Using the arrows key put vi in the insertion mode. Use :q! to exit without saving the changes. -rw-r--r-- 1 spantaro students 0 May 22 23:44 newfile drwx------ 2 spantaro stufdsfdsfdsfdffdsfsents 1536 Apr 28 2000 prokids drwx------ 2 spantaro students 512 Mar 30 13:06 public-web -rwxr 10.3.1) Used vi to open a long document (README). 10.3.2) Used Ctrl-f to see the next screen full. 10.3.3) Used Ctrl-u to go up half screen. 10.3.4) Used w to move word by word. 10.3.5) Used Ctrl-b to move backward. It stopped in a certain position, that was not the first character of the file and did not move anymore. 10.3.6) Noticed that W and w produced different movements. 10.3.7) Capital B moves backward word by word. 10.4.1) Created a new file called buckaroo. internet% vi buckaroo 10.4.2) Tried to type but vi beeped due to the fact that I am not in the insert
mode and it understood to move down a line that does not exist yet Then
typed i and could insert letter k. k ~ 10.4.3) Backspace moved the cursor over k. Pressed escape and the k was deleted. k in the command mode deletes a character. Vi only saves text you've entered to the left of or above the cursor, not the letter the cursor is resting on. 10.4.4) Typed i and inserted the following text. He's not even here," wnet the cnonservation. "Banzai" "Where is he?" "At a hospital in El paso." "What ??? Why weren't we informed? What's wrong with him?" ~ ~ ~ "buckaroo" [New file] 10.4.5) Used the cursor motion keys to move to the first line, and 'o' to open a new line bellow. He's not even here," wnet the cnonservation. "Banzai" "Where is he?" "At a hospital in El paso." "What ??? Why weren't we informed? What's wrong with him?" ~ 10.4.6) Used O to open a new line above a current line. Blab blab bla He's not even here," wnet the cnonservation. "Who?" "Banzai" "Where is he?" "At a hospital in El paso." "What ??? Why weren't we informed? What's wrong with him?" ~ ~ ~ 10.4.7) Used 'a' to append a text to a certain position in a line. Learned the 'aa' trick that the author gave. 10.4.8) Used 'i' and 'a' to insert and append text. 10.4.9) Quit vi without :q and it reminded me that I haven't saved the file. Blab bababababa jhkhkhkhfkhkfhsggggggkblab bla He's not even here," wnet the cnonservation. "Who?" "Banzai" "Where is he?" "At a hospital in El paso." "What ??? Why weren't we informed? What's wrong with him?" ~ ~ No write since last change (:quit! overrides) 10.5.1) Typed x to delete some characters. Typed u and the last deletion was back again. Typed u again and noticed that the character was deleted again. 10.5.2) Typed dw twice and two words were deleted. Typed u and the last word deleted was recovered. Typed U and the whole entire line was restored to its original form, all the deleted words were recovered. 10.5.3) Typed dd to delete the whole line. Move to a line and moved cursor to the middle of the line and typed D to delete everything after the cursor. Typed u to undo the deletion of the text. 10.5.4) Typed dd twice and two lines were deleted. Typed u and only the last deleted line was recovered. 10.5.5) Quit vi using :q! to discard all the changes made to the current file. Typed 'vi buckaroo' to edit the file. 10.5.6) Used the keyboard key to move around and made corrections. Used w to jump word by word, used dw to delete wrong words, and i to insert corrected ones. 10.5.7) Used tilde (~) to change lower p by capital P. 10.5.8) Used x to remove an extra quote in the file. |