There certainly is Vim style searching in bash/readline. In fact, your command line is essentially a scaled down version of the Vim editor with a significant number of Normal mode commands available to you. More on that in a sec but first Search. The key piece of information you need is that as you stare at that blinking cursor on your command line you are in the equivalent of Vim's Insert mode. So how do we get to Normal mode? By hitting Esc, of course.
From there hit /, enter a search term and hit Enter. Now you can use n and N to move back and forth through the results. (You'll effectively be searching backwards by default with
n...searching forwards from the start wouldn't give any results since there's no history in the future!) To execute the current result as a command hit Enter again.
Don't forget that you're in Normal mode, though, so if you don't find what you're looking for and want to get back to entering text in Insert mode do what you usually do in Vim. Hitting i, for example, will do it. Or you can use Vim command
C which will remove any text after the cursor and enter Insert mode, which is handy. (You can precede that with
0 if you moved the cursor past the first column.) Or use
Ctrl-C...you get the picture.
Besides the various commands that enter Insert mode you get can navigate with
$, etc. Yank/delete/put are there, too, and you can use them in them in action+navigation commands like
d$, etc.1 Finally,
undo works as well! Go ahead and try some other stuff yourself.
Oh, and if you get a bit lost or, as happens to me once in a while, some funkiness with line wrapping scrambles your c/l you can drop the pretense and hit
v. This pulls your command line's contents into an actual instance of Vim so you can edit with a Fully Armed and Operational Text Editor. Once done,
:wq to submit what you have to the shell for execution.
1Alas, the operator+motion commands (
yap, etc.) aren't supported. But @EdNeville's comment below has a link to some readline settings that will add seemingly every op-motion command there is as well as a number of others. You can really round out your command-line based Vim experience by adding them to your .inputrc file.
Additional Info: You are not restricted to using just what
set -o vi or
set -o emacs gives you. You can use any of the available readline commands. I believe
Ctrl-R should be available even in Vim mode but if not you can try putting this in your
set editing-mode vi
Better yet, you can add some otherwise unavailable commands like
With this, once you have selected a command from history (e.g. via Vim search) hit
Ctrl-O instead of
Enter and Bash will run the command and insert the next command from history, ready to run.
See Readline Command Names section in the Bash manpage for complete list.
(You can also configure these from the command line with the
bind command but I'm already getting too far afield here.)