When you first enter vi, you are in command mode. To enter the last line mode press :. If successful, your cursor should appear in the bottom line of the screen. From last line mode, you return to command mode after pressing enter. Only way of going to insert mode is pressing i,I,a,A,o or O in the command mode. To return back to command mode from insert mode, press the escape key.