VI Commands


  To move:    h (left)       j (down)       k (up)       l (right)

  Delete from the cursor to the end of a word:    dw

  Delete from the cursor to the end of a line:    d$

  To undo the last action only:                   u   (lowercase u)
  To undo all the changes on a line:              U   (capital U)

  To replace text that has already been deleted:  p

  To replace the character under the cursor:      r

  To replace from the cursor to the end of word:  cw
  To replace from the cursor to the end of line:  c$

  Ctrl-g  displays your location in the file and the file status.
  Line number followed by Shift-G moves to that line number.

  Typing % while the cursor is on a (,),[,],{, or } locates its matching pair.

   To substitute new for the first old on a line type    :s/old/new
   To substitute new for all 'old's on a line type       :s/old/new/g
   To substitute phrases between two line #'s type       :#,#s/old/new/g
   To substitute all occurrences in the file type        :%s/old/new/g
   To ask for confirmation each time add 'c'             :%s/old/new/gc

  :#,# FILENAME  saves the lines # through # in file FILENAME.

  :r FILENAME  retrieves disk file FILENAME and inserts it at cursor position.

  Typing o opens a line BELOW the cursor and places you in insert mode.
  Typing a capital O opens the line ABOVE the line the cursor is on.

  Typing a capital R enters replace mode until  is pressed to exit.

  Typing ":set xxx" sets the environment variable "xxx"


If you would like me to add some more useful VI commands please email me at: feuerbac@cs.ucf.edu