Editing in vi
vi always starts in Command mode. True editing takes place in what's known as Insert mode. The keys you commonly use to invoke Insert mode from Command mode are
iThe most common method of moving into Insert mode is to press the i key, leaving the cursor at the current position. All typing from that point pushes existing text to the right.
IThe uppercase I key moves to the beginning of the current line and from there acts like the i key.
aThe second most common method is to press the a key, moving the cursor one character to the right, essentially behaving like an i key after that.
AThe uppercase A moves to the end of the current line and from there acts like an a key.
oUse this key to open a new line under the present line. For example, if you're on line 3 in Command mode, pressing o drops line 4 down to become 5 and opens a new line 4 that's empty.
OThe uppercase O opens a new line at the current line. For example, if you're on line 3, pressing O drops line 3 down to become line 4 and opens a new empty line 3 for editing.
If you press one of the previously mentioned Insert mode keys, in the bottom left of the vi screen (the left end of the Message Line) the following text appears:
Getting back to Command mode is easy: Press the Esc key at least once, although many people double-press it just to make sure they're really there. At any time you can return to Command mode from Insert mode by pressing the Escape key (Esc).
The Message Line
The bottom of the vi screen should contain a number of pieces of information that can help you, varying to suit the situation and actions just completed. This section details some of the messages that can appear.
If you've just entered vi file1, when the editor opens the file, the message line should contain something similar to the following:
"/home/rbrunson/file1" 57L, 1756C 18,1 Top
The numbers 18,1 on the right side of the message line are the current line and column numbers, and the Top text is the current position of the cursor. This changes to be Bot if you entered the last half of the file. The other value possible is All, which simply means that all the contents of the file are currently on the screen.
A new file (one invoked with vi file1) would show the line:
"file1" [New File] 0,0 All