Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I recently switched the history search to use history-incremental-pattern-search-backward since it allows for patterns in the search. Here is how it is setup in my .zshrc

bindkey -M vicmd '/' history-incremental-pattern-search-backward

This works great, but I can't figure out how to go to the next match from the search menu.

% cat foobarbaz.txt
bck-i-search: f*baz

Is there a key bound to do this?

share|improve this question
up vote 7 down vote accepted

Finally found the right incantation. You need to map the pattern search in insert mode. This was the piece I was missing:

# Search backwards and forwards with a pattern
bindkey -M vicmd '/' history-incremental-pattern-search-backward
bindkey -M vicmd '?' history-incremental-pattern-search-forward

# set up for insert mode too
bindkey -M viins '^R' history-incremental-pattern-search-backward
bindkey -M viins '^F' history-incremental-pattern-search-forward

I would have used ^B for backwards search in insert mode, but I have that mapped to something else. So now ^R and ^F cycle through the matches.

share|improve this answer

According to the zshzle manual page for zsh 4.3.10, no key is bound by default. You need to add bindings to the isearch map, and only a few widgets are available. For instance, you can do:

bindkey -M isearch '^R' history-incremental-search-backward
bindkey -M isearch '^S' history-incremental-search-forward
share|improve this answer
bindkey -l does not show an isearch mapping – claytron Oct 10 '10 at 16:25
@claytron: must be a version issue: isearch is new in 4.3.10, while history-incremental-pattern-search-backward appeared in 4.3.7 (if I read the changelog correctly). – Gilles Oct 10 '10 at 16:54
I'm using 4.3.10, not sure why it isn't there. Using the insert mode bindings worked for me though. – claytron Oct 10 '10 at 18:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.