Class 10 of 37 • VI Editor Mastery \t\t\t\t

Types of Modes in VI Editor

in vi editor are three mode available command mode,input mode,execution mode,the following discription of all mode in the details.

VI and Vim Text Editor 3 Operating Modes: Command Mode, Insert Mode, and Ex Mode Diagram

Figure 7: Complete state transition diagram between Vi Editor's three modes.

1. Command Mode (Default)

      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.

2. Input Mode (Insert / Editing Mode)

      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.

3. Execution Mode (Ex / Last-Line Mode)

      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).


Mode Switching Quick Reference Table

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.

Frequently Asked Questions (FAQ)

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.

Next Step in Your Linux Learning Path:

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

Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Stumbleupon Share on Tumblr Share on Reddit Share on Diggit

You may also like this!