- Control + g -----> Check the number of lines. - G -----> GO to the end of the file. - cc -----> Replace the entire line. - Control + l -----> Redraw the screen. - D -----> REplace the entire line starting at the cursor. - J -----> Joining 2 lines. - :sh -----> give several Unix commands in a row w/o returning to VI, when done press Control + d. - :r !date -----> read into the system's date and insert the info below the current cursor. - :r !sort phone -----> read into the "phone" file then sort it, then insert the contents of the file "phone" below the current cursor. - :r file -----> Append the contents of the file "file" below the current cursor. THis is how to do appending in VI. - :set number -----> Display line number in VI. - :set nu -----> Display line number in VI. - :.# -----> Display the current line number. - :.,+10# -----> DIsplay the current line number AND the next 9 lines with preceding line number (for a total of 10 lines). - := -----> print the total number of line. - :/pattern/= -----> Print the line number of the first one that matches pattern.st - :set nonumber -----> DO not display line number. - :set nonu -----> DO not display line number. - :set window=20 -----> set the number of lines shown in the screen's window. - :set ic -----> specify search pattern should ignore case. - :set noic -----> specify search to be case sensitive. - The .exrc file controls your VI environment and it is in your home directory. - :1,10!sort -----> Sort from line 1 thru line 10. - !) then we will see at the bottom of the screen the "!" sign, typing tr '[a-z]' '[A-Z]' will change all lower cases letters into upper cases letters. - !10+ then we will see the "!" sign at the bottom of the screen. by typing tr '[a-z]' '[A-Z]' will change all lower case letters into upper case letters from the current line up to the next 9 lines.(for a total of 10 lines) - :.,$d -----> Delete from current line to the end of file. - %d -----> Delete all lines in the file. - :.,.+20d -----> Delete from current line thru the next 20 lines. - :/pattern/d -----> Delete the next line that conatins "pattern" - :/pattern1/, /pattern2/d -----> Delete from the firrst line containing pattern1 thru the first line containing pattern2. - :g/pattern/p -----> Finds and displays all lines in the file containing pattern. - :1,20w newfile -----> will save line 1 to line 10 to the file "newfile". - :20,$w newfile -----> will save the contents from line 20 to the end of the file to the file "newfile". - :1,$s/old/new/g -----> change ever occurence of "old" to "new" within the entire file. - :%s/old/new/g -----> change ever occurence of "old" to "new" within the entire file. - :g/^$/d -----> Delete ALL blank lines. - :g/^[ tab]*$/d -----> Delete ALL blank lines but with white spaces and tab(s) in that line (non-readable cahracters).