9.1 The vi Editor
9.1.3 Opening files with vi
The vi editor is a UNIX text editing application which is started from the command line. Whenever you start vi, you are opening a file. You can specify the file you want to create or edit when you start vi or you can open a new file to be named later. The most basic steps in using vi are:
  • open a new file,
  • input some text,
  • save it to disk, and
  • exit vi.
Command Format:  
vi [option(s)] [filename]

Methods of Invoking vi

  1. vi filename - This specifies the file name at the time vi is started. If the file exists, it is opened for editing. If the file does not exist, it is created. When you issue the write command in last-line mode, this file is updated.
  2. vedit - Starts the vi editor with showmode turned on. Showmode displays the entry or input mode you are currently in (Insert, Append or Open) at the lower right corner of the screen. If you are in command mode, nothing is displayed. If you are in last-line mode, your cursor will usually be in the lower left corner with a colon displayed. You may also enable showmode after you have started vi by entering set showmode at the colon in last-line mode. Use vedit when possible so you will know what mode you are in.