How do you search through Vim's command history?

Viewed 56406

I would like to have the following search in Vim too

(reverse-i-search)`':

Enter a word of your previous command, and you get the full command.

I know the chronological history tool in Vim

q:

However, it is not that useful as the fuzzy reverse search.

How can you have a similar reverse search in Vim as in the terminal?

6 Answers

Enter the first letters of your previous command and push <Up> arrow (or Ctrl+p).

:set li<up>
:set lines=75

Don't forget to check history option and set it to big enough value

:set history=1000

Press Ctrl+F in command mode to open the command history window. Then, you can use / , ? , and other search commands. Press Enter to execute a command from the history.

For more about the command history window, see :h cmdwin .

Here are the docs for Vim's commandline history, also see this part of the docs on Vim's commandline history that covers the key bindings while in the history. It looks like you can say :foo and then hit the up arrow to find the last command that started with foo.

Related