Linux Vi Undo And Repeat

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

vi undo and repeat

In command mode, to undo the last command is used and if you want to repeat the last command use dot (.).

u

This command allows us to undo or cancel our last command.

Example:

Linux-Undo and Repeat1

Look at the above snapshot, this is our script.

Linux-Undo and Repeat2

Look at the above snapshot, with the help of dG command we have deleted last lines.

Linux-Undo and Repeat3

Look at the above snapshot, after pressing u, last command dG disables and all the content came back.

(.)

The . command allows us to repeat last used command.

Example:

Linux-Undo and Repeat4

Look at the above snapshot, we have used D command to delete some part of line second.

Linux-Undo and Repeat5

Look at the above snapshot, after pressing . same D command is repeated on line four.