Mathematics
 
 
MTH 568 - Compuational Science

 

Home
 

Syllabus
 

Course Outline
 

Resources
 

Contact Info


 
Editting Text with vi




The VIsual editor (vi) is one of the most commonly used editors for working with text files in Unix.  The vi editor is complete with a series of commands that allow one to easily replace, delete, or move characters, words, paragraphs, data structures, or lines of code.
 
 

     
  • Starting vi
    • Log into Unix account
    • Bring up a console
    • Type vi newfile at the shell prompt
    • Enter insert mode by pressing i
    • Enter is some text
    • Exit insert mode by pressing <Esc> - you have now entered command mode
    • Exit vi by typing :wq (for write and quit)

     
  • Navigating Through a Text File
    • Open "newfile" in vi by typing vi newfile at the shell prompt
    • Command mode - h, j, k, l to move around file

     
  • Adding, Changing, and Deleting Text
    • To insert text, move cursor to desired location and type i to enter insert mode
    • Insert desired text and press <Esc> to exit insert mode and to continue navigating through file
    • To delete a character type x in command mode
    • To replace a character type r in command mode, followed by the new character

     
  • Exiting vi
    • To exit without saving changes, type :q! in command mode
    • To exit and save the file under a new name, type :w newfilename

     
  • Commands for vi and Further Information