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?


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

  • 1
    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
  • 1
    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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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