OpenWindows Advanced User's Guide

6.2.2 Command Mode

When you open a file with vi, you are in command mode. In this mode, you can enter commands to implement a wide range of functions. Most vi commands consist of one or two letters and an optional number. Usually, there are upper and lowercase versions of commands that perform related but different functions. As an example, typing a appends the file to the right of the cursor, while typing A appends the file at the end of the line.

Most vi commands don't require that you press Return to execute them. Commands beginning with a colon (:), however, do require that you press Return after the command. Some discussions of the vi editor refer to commands preceded with a colon as a third, and uniquely separate mode of vi, last-line mode. This is because when you type the colon while in command mode, the colon and the remainder of what is typed appear on the bottom line of the screen. For the purpose of this discussion, however, all vi commands are initiated from command mode.

Commands preceded with a colon are actually ex commands. vi and ex are two separate interfaces to the same text editing program. While vi is a screen-oriented interface, ex is a line-oriented interface. The full set of ex commands is available from within vi. When you press the colon, you are actually switching to the line-oriented, ex interface. This allows you to perform many file manipulation commands without ever leaving vi. See "6.6 Using ex Commands", in this chapter, for further information.