Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 12 down vote accepted

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 @:.

share|improve this answer
I wish I could +10, having this feature makes using the vim command mode much nicer. I personally use a few remaps to make it easier to access. – evilsoup Feb 9 '14 at 13:28
I wish I could +10 for adding a quick animation. – mtk Feb 12 '14 at 15:54

Entering : and then the beginning of the command previously issued followed by Up will retrieve the matching command. If there is more than one option available, you can cycle through them with Up and Down.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.