Using VI File Editor

VI For Beginners:

There are many advanced tutorials on how to use vi, as it is very complex. The only way to learn vi is to use it. The following is a list of the most common commands that you can using when editing files in vi.

A couple things to note before you begin:

Commands can be given to vi in two different ways. You can supply a command in 'command mode' by using ':' or directly in the document while you are not in 'insert mode'.

Don't get frustrated before you have a chance to become comfortable with vi. It can be difficult to learn but if you use it frequently you will become quite familiar and comfortable using vi.

  1. Opening a document
    1. To open an existing document:
      # vi (filename)

    2. To open a new document:
      # vi (new filename)
  2. Editing the document
    • Cancel current mode
    • : Enter command mode
    • i Enter insert mode
    • :q quit the document
    • :q! quit the document and do not save
    • :w save the document
    • :wq save and quit the document
    • dd delete current line
    • x delete character
    • yy copy the line to the clipboard
    • p paste the clipboard

Once you have mastered the basics you can move on to some of the more advanced features.