For years, two text editors have held equal sway in Unix culture: vi and Emacs. Not one to take sides, Mac OS X ships with both of them. The following two sections give you a whirlwind tour of both.
You don’t have to use one of these editors in order to open a text document from a Terminal window. You can instead use the open command with its -a (application-specifying) option to send the document to an Aqua text editor, such as TextEdit, like this:
open -a TextExit
vi is a modal editor, signifying that the meaning of what you type at any point depends entirely on what mode (context) the program is in. vi’s modes include command mode (see Section 188.8.131.52), which performs deletion, cut-and-paste, searching, and other text-editing commands, and insertion mode, which adds new text to the document through typing.
The three most common ways of starting a vi session are:
You can open file for editing, optionally at line n or at the first line matching pattern. (See Chapter 20 for more on pattern matching.) If no file is specified, vi opens with an empty buffer. See Chapter 25 for more information on command-line options for vi.
Once the file is opened, you are in command mode. From here, you can:
Invoke an insert mode
Issue editing commands
Move the cursor to a different position in the file
Invoke a Unix shell
Save or exit the current version of ...