Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
add comment

2 Answers

up vote 10 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
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 at 13:28
    
I wish I could +10 for adding a quick animation. –  mtk Feb 12 at 15:54
add comment

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
add comment

Your Answer

 
discard

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.