Command reverse search in vim

searchvim

In linux cli I can do ctrl-r and do a reverse search and choose something I have done easily.
Is there something similar in vim? I mean I may run a command using : (could be anything like a long substitution) and if I need to do it again I need to retype it.
Is there a way to avoid retyping but instead somehow search back and execute it?

Best Answer

You may find q: useful. It opens the command-line window. The command-line window looks like this:

enter image description here

I tried to make an animation of its usage:

Animation of q:

Also see c_CTRL-F, which opens the command-line window from command mode.

You can also re-run the last command from normal mode by typing @:.

Related Question