Vim provides many commands which make editing functionality really powerful. In this chapter, we will discuss following items −
To insert text before cursor perform following steps −
i
Let us suppose you are in the middle of line and you want to insert text at the beginning of current line then perform following steps −
Esc
I
This action will move cursor to the beginning of current line and switch Vim in insert mode
To append text after cursor perform following steps
Esc
a
This action will move cursor next by one position and switch Vim in insert mode.
Let us suppose you are in the middle of line and you want to append text at the end of current line then perform following steps −
Esc
A
This action will move cursor to the end of line and switch Vim in insert mode
Let us suppose you are in the middle of line and you want to open new line below current line then perform following steps −
Esc
o
This action will insert blank line below current line and switch Vim in insert mode
Let us suppose you are in the middle of line and you want to open new line above current line then perform following steps −
Esc
o
This action will insert blank line above current line and switch Vim in insert mode
Let us suppose you want to substitute single character then perform following steps −
Esc
s
This action will delete character under cursor and switch Vim in insert mode To substitute entire line use −
s
This action will delete entire line and switch Vim in insert mode.
Let us suppose you want to change text in current line then perform following steps −
Esc
cc
This is similar to substitute action using S
To change text from current cursor position, execute following command
C
This action will delete text after current cursor position and switch Vim in insert mode.
To replace single character perform following steps −
Esc
r
Note that this command will not switch Vim in insert mode
To replace entire line execute −
R
It will switch Vim in replace mode as shown in below image −
To join two lines perform following steps −
Esc
J