I had the problem when I started using Vim and the following advices helped me a lot.
Before the command is finished
If your buffer is not yet modified but your are in the middle of a command (e.g.: di
) you can simply escape and cancel the command using Esc
If you add to your .vimrc
file:
set showcmd

you'll see at the bottom right of the screen the command partly entered.
If you add to your .vimrc
file:
set notimeout
Vim will wait forever that you complete the command (and not cancel it after a timeout). I found that useful to let me see what I'm typing in normal mode.
After the command has been executed
If your buffer has been changed and you want revert it back you can:
- Go to normal mode using Esc
- Undo your changes using
u
Advice: Switch back regularly to Normal mode when you edit files (insert text) such that the granularity of the undo is fine enough.
Stuck in other modes
Busy recording a macro
If you hit qa
you are busy recording macro a
. You have in the bottom left a text telling you recording @a
.

To stop you can either type Ctrlc to cancel the recording or q
to stop the recording.
In the Ex
mode
If you hit Q
you are in the Ex
mode:

To leave the visual mode you have to type visual
Enter
The Ex
mode is very exotic. A number add:
nnoremap Q <Nop>
This prevent you to go the Ex
mode.
In the "Ed
" mode
If you hit :i
Enter or :a
Enter you enter in "Ed
" mode:

In this mode you have no visual clue to indicates you that you are in that mode.
You type a text that will be inserted if you validate it with .
Enter
To leave the "Ed
" mode without inserting anything you can type Ctrlc to go back to Normal
mode.
In Summary
If you hit twice Ctrlc you can be nearly sure you are back to normal mode (with the only exception of Ex
mode that I advice you to deactivate)
Cursor move
Sometime your buffer isn't changed but your cursor is moved. You can use: Ctrlo to moves it back to the previous location.
If you go too far back you can use: Ctrli to move forward in the history.
u
, and "redo" withCTRL-R
G
key to hope to a line number but the cursor isn't budging. One thing i did to make vim behave again was start command mode with:
then hit escape, but it's honestly not worth using imo if i have to do that.G
key stops working but all the other keys still do work?