in vi editor are three mode available command mode,input mode,execution mode,the following discription of all mode in the details.
Figure 7: Complete state transition diagram between Vi Editor's three modes.
It is the mode where you will be giving commands to vi editor.
When you invoke vi,this is the mode where you will be placed initially.
Move cursor with h (left), j (down), k (up), l (right).
Cut lines with dd, copy with yy, and paste with p.
In this mode,user can add text to the file.
It is also called editing mode.
When you want to insert at the current cursor position,give command i.
You will now get placed in the input mode and you can perform adding text.
No command can be given while you are in the input mode.
To move back to the command mode press "ESC" key.
It enables you to give commands at the command line.
To move to the ex mode,press ":"(colon) if you are in command mode.
If you are in the input mode.first press "ESC" key and then press ":" to move the ex mode.
Used for saving (:w), quitting (:q!), and search/replace (:%s/old/new/g).
| From Mode | To Mode | Key to Press | Description |
|---|---|---|---|
| Command | Insert | i | Insert text before cursor. |
| Command | Insert | a | Append text after cursor. |
| Command | Insert | o | Open a new line below and enter insert mode. |
| Insert | Command | Esc | Exit insert mode back to command mode. |
| Command | Ex Mode | : (colon) | Brings cursor to bottom command line prompt. |
| Ex Mode | Command | Enter or Esc | Executes ex command and returns to command mode. |
When in Insert Mode, Vi/Vim displays -- INSERT -- at the very bottom left of your screen. In Ex Mode, a colon : prompt appears at the bottom. If there is no indicator and keystrokes do not appear as text, you are in Command Mode.
Press Esc to ensure you are in Command Mode, then type :q! and press Enter. The exclamation mark forces Vi to quit immediately and discard all edits made since the last save.
Supercharge your productivity with navigation, search, and substitution in Class 11: VI Commands Master Cheat Sheet.
Continue to Class 11: VI Commands Cheat Sheet → Previous: ← Features of VI | Full Syllabus