Moving the Cursor
When you start vi, the cursor is in the upper left corner of the vi screen. In command mode, you can move the cursor with a number of keyboard commands. Certain letter keys, the arrow keys, and the Return key, Back Space (or Delete) key, and the Space Bar can all be used to move the cursor when you're in command mode.
Most vi commands are case sensitive. The same command typed in lowercase and uppercase characters might have different effects.
Moving With Arrow Keys
If your machine is equipped with arrow keys, try these now. You should be able to move the cursor freely about the screen by using combinations of the up, down, right, and left arrow keys. Notice that you can only move the cursor across already existing text or input spaces.
If you're using vi from a remote terminal, the arrow keys might not work correctly. The arrow key behavior depends on your terminal emulator. If the arrow keys don't work for you, you can use the following substitutes:
To move left, press h.
To move right, press l.
To move down, press j.
To move up, press k.
Moving One Word
Press w (“word”) to move the cursor to the right one word at a time.
Press b (“back”) to move the cursor to the left one word at a time.
Press W or B to move the cursor past the adjacent punctuation to the next or previous blank space.
Press e (“end”) to move the cursor to the last character of the current word.
Moving to Start or End of Line
Press ^ to move the cursor to the start of the current line.
Press $ to move the cursor to the end of the current line.
Moving Down One Line
Press the Return key to move the cursor to the beginning of the next line down.
Press the Back Space key to move the cursor one character to the left.
Press the Space Bar to move the cursor one character to the right.
Moving to the Top
Press H (“high”) to move the cursor to the top of the screen.
Moving to the Middle
Press M (“middle”) to move the cursor to the middle of the screen.
Moving to the Bottom
Press L (“low”) to move the cursor to the bottom of the screen.