Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you search through Vim's command history?

Tags:

vim

search

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?

like image 374
Léo Léopold Hertz 준영 Avatar asked Apr 12 '09 15:04

Léo Léopold Hertz 준영


People also ask

How do I search command line history?

Open a terminal application on your Linux or Unix and type history to list all commands. To search for a command in the history, press ctrl+r multiple times. For instance, you can hit the ctrl+r and type string to search.

How do I find vim command history?

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.


2 Answers

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.

like image 160
sumek Avatar answered Nov 10 '22 23:11

sumek


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 
like image 28
Mykola Golubyev Avatar answered Nov 10 '22 21:11

Mykola Golubyev