z/OS UNIX System Services User's Guide
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Basic principles

z/OS UNIX System Services User's Guide
SA23-2279-00

To begin using vi, you type the command:
vi filename
where filename is the name of a file you want to edit. This can be an existing file, or it can be a new file that you want to create.

The vi command begins a vi session. In a vi session, you enter input that creates or changes the contents of the file specified on the command line. vi reads and uses the input you type until you quit your vi session.

In a vi session, you are always in one of two modes:
  • Insert Mode, in which everything you type is taken as text input. vi displays text on the screen as you enter it. Eventually, vi stores this text in a file.
  • Command Mode, in which vi interprets everything you type as a command to change the text in some way. Usually, commands do not appear on the screen—you just see the effects of the command. For example, if you enter the command to delete a line of text, you see the line disappear, but you never see the delete line instruction that you actually typed.

To switch from Insert Mode to Command Mode, simply press the key marked <Esc>. If you are not sure which mode you are in, press <Esc> several times. This always brings you back to Command Mode.

To delete a character, you must be in Insert Mode. Pressing <Backspace> deletes the last character you typed; pressing <Backspace> twice deletes the last two characters, and so on. vi usually does not immediately delete these characters on the screen—it just backs up the cursor so that anything you enter is typed over the characters that were there. When you leave Insert Mode, vi adjusts the screen to remove any characters that were deleted by <Backspace> and not over-typed.

To quit a vi session, do one of these:
  • :wq to save your changes and quit vi
  • :q! to quit without saving your work

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014