Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

What are the different mode of Vi-editor? How can change from one mode to another.

Vi and its advanced version Vim have three main modes:

1. Command Mode:

  • This is the default mode when you open a file.
  • Every character typed is interpreted as a command to edit the text.
  • Common commands include:
    • i: Enter insert mode.
    • a: Append text after the current cursor position.
    • o: Open a new line below the current line.
    • x: Delete the character under the cursor.
    • dd: Delete the current line.
    • :w: Save the file.
    • :q: Quit the editor.

2. Insert Mode:

  • This mode allows you to enter text and edit the file content.
  • Any text you type is inserted at the current cursor position.
  • To switch to insert mode, press the i key.
  • To return to command mode, press the Esc key.

3. Visual Mode:

  • This mode allows you to select text for editing or deletion.
  • To enter visual mode, press the v key in command mode.
  • To move the cursor while selecting text, use the arrow keys.
  • To return to command mode, press the Esc key.

How to change from one mode to another?

To enter insert mode:

  • Press i from command mode.
  • Press a to append text after the cursor.
  • Press o to open a new line below the current line.

To enter command mode:

  • Press Esc from any other mode.

Vi and its advanced version Vim have three main modes:

  1. Command Mode:

This is the default mode when you open a file.
Every character typed is interpreted as a command to edit the text.
Common commands include:
i: Enter insert mode.
a: Append text after the current cursor position.
o: Open a new line below the current line.
x: Delete the character under the cursor.
dd: Delete the current line.
:w: Save the file.
:q: Quit the editor.

  1. Insert Mode:

This mode allows you to enter text and edit the file content.
Any text you type is inserted at the current cursor position.
To switch to insert mode, press the i key.
To return to command mode, press the Esc key.

  1. Visual Mode:

This mode allows you to select text for editing or deletion.
To enter visual mode, press the v key in command mode.
To move the cursor while selecting text, use the arrow keys.
To return to command mode, press the Esc key.
Here’s how to change from one mode to another:

To enter insert mode:

Press i from command mode.
Press a to append text after the cursor.
Press o to open a new line below the current line.
To enter command mode:

Press Esc from any other mode.

To enter visual mode:

  • Press v from command mode.
  • Use the arrow keys to select text.
  • Press Esc to return to command mode.