How do you search through Vim's command history?

SearchVim

Search Problem Overview


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?

Search Solutions


Solution 1 - Search

Type q: in the normal mode to open commands window. You can search/edit here using regular vim commands. You start in Normal mode. Press Enter to execute a command.

This approach lets you search across whole command not just beginning of line.

Solution 2 - Search

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

Solution 3 - Search

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 .

Solution 4 - Search

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.

Solution 5 - Search

With FZF fuzzy search command: :History:

Source: https://github.com/junegunn/fzf.vim

Solution 6 - Search

I was looking for this as well (finally after wondering why it wasn't built-in for some time) and decided I couldn't resist whipping up an implementation, so here you go: https://github.com/goldfeld/ctrlr.vim

It should work just like the shell's--well there are still a couple basic things missing (like pressing ^R again to skip to next match), but all that I use is in this first release, and I plan to add the rest in the coming weeks as I get time.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionL&#233;o L&#233;opold Hertz 준영View Question on Stackoverflow
Solution 1 - SearchsumekView Answer on Stackoverflow
Solution 2 - SearchMykola GolubyevView Answer on Stackoverflow
Solution 3 - SearcheligView Answer on Stackoverflow
Solution 4 - SearchChas. OwensView Answer on Stackoverflow
Solution 5 - SearchJesus HView Answer on Stackoverflow
Solution 6 - SearchVic GoldfeldView Answer on Stackoverflow