Linux Vi Switch

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

vi switch from command mode

To start typing in vi editor, you have to be in insert mode. There are different commands in vi editor through which you can start typing at different locations in insert mode. They are defined below.

i

The command allows us to write before the current character.

Example:

Linux vi Switch1

Look at the above snapshot, our cursor is at e. We forgot to write word command before word example. Hence, here we can use i command.

Linux vi Switch2

Look at the above snapshot, after pressing i, we wrote word command.

I

The command allows us to write at the start of the current line.

Example:

Linux vi Switch3

Look at the above snapshot, we want to write word Hello at the starting of the line.

Linux vi Switch4

Look at the above snapshot, after pressing I, we have typed Hello at the starting of the line.

A

The A command allows us to start typing at the end of the current line.

Example:

Linux vi Switch5

Look at the above snapshot, we want to move at the end of the current line.

Linux vi Switch6

Look at the above snapshot, after pressing A, we have written one more line.

o

The command allows us to start typing a new line after the current line.

Example:

Linux vi Switch7

Look at the above snapshot, we are at the middle of the line and want to start a new line.

Linux vi Switch8

Look at the above snapshot, after pressing o, we arrived at next line and typed there.

O

The command allows us to start typing on a new line before the current line.

Example:

Linux vi Switch9

Look at the above snapshot, we are at the middle of the line and want to write before the current line.

Linux vi Switch10

Look at the above snapshot, after pressing O, we have written in a new line before the current line.