The vi editor has two modes of operation: command or insert. In command mode, vi allows you to navigate around your file and enter commands. To enter new text, put vi into insert mode. In command mode, the keyboard keys are interpreted as vi commands instead of text. The convenience of being able to manipulate the editor without moving your hands from the keyboard is considered one of vi’s strengths.
Commands are brief, case-sensitive combinations of one or more letters. For example, to switch from command to insert mode, press the “i” key. To terminate insert mode, press the Escape key (Esc), which puts you back in command mode.
Almost any command can be prefixed with a number to repeat the
command that number of times. For example,
r will replace the character at the current
cursor position. To replace exactly 10 characters, use
10r. Commonly used vi
commands are listed in Table 6-12.
Table 6-12. vi commands
Move left one character.
Move down one line.
Move up one line.
Move right one character.
Move to the top of the screen.
Move to the bottom of the screen.
Move to the end of the file.
Move forward one word.
Move backward one word.
Move to the beginning of the current line.
Move to the first nonwhitespace character on the current line.
Move to the end of the current line.
Move up (back) one screen.
Move down (forward) one screen.
Insert at the current cursor position.