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?
2 Answers
You may find q: useful. It opens the command-line window. The command-line window looks like this:

I tried to make an animation of its usage:

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 @:.
-
1I 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– evilsoup2014-02-09 13:28:41 +00:00Commented Feb 9, 2014 at 13:28
-
1I wish I could +10 for adding a quick animation.mtk– mtk2014-02-12 15:54:40 +00:00Commented Feb 12, 2014 at 15:54
-
Just adding that in the command-line window one can search as usual with
/. Hitting enter executes the current line and closes the window.leftaroundabout– leftaroundabout2024-11-22 11:15:15 +00:00Commented Nov 22, 2024 at 11:15
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.
-
Wonderfully useful! TNX 1.0E6Jostein Topland– Jostein Topland2018-11-30 08:38:23 +00:00Commented Nov 30, 2018 at 8:38