We can retrieve search and replace history on IDEs and text editors. Likewise is there a search history or a way to retrieve previously searched expression in vim?
Yes, you have the history
command:
:history /
Note that it can be used for /
, :
, =
, >
, ?
, @
, all
, cmd
, debug
, expr
, input
and search
.
Alternatively you can use the q:
, q/
and q?
commands to see previously entered commands and searches on a sepearate buffer. You can then modify as you want and replay them by pressing <CR>
.
See :h :history
, :h q:
.
-
1
-
4As for replace, one can look at
q:
. It's not exclusive to replaces, but it's a real buffer, so all of vim's power works there. – PhilippFrank May 10 '16 at 11:54 -
1
-
4Related Vimcasts episode: Refining search patterns with the command-line window – Peter Rincker May 10 '16 at 14:14
You can use :history s
for search history. As a shortcut, you can use :his s
. Same way for command line history also.