Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: vi-history-search(forward|backward) vicmd mappings

On Jan 23, 11:30pm, Larry Hynes wrote:
} In fact, if one enters '<ESC>?' on a zsh command line with
} 'bindkey -e' in effect the mini-buffer prompt becomes '/' to
} signify a forward search, and '<ESC>/' produces a '?' to signify
} a backward search, so I propose that the default mappings are,
} perhaps, backwards?

This is intentional.  I've always thought it was a bit weird, but
the reasoning (from 20+ years ago) goes like this:

The vi-*search-* widgets don't include the current buffer, and even
if they did the most common place to invoke a search is at the end
of the command line, and the history only extends backwards in time;
so for all those reasons it almost never makes sense to search in
the "forward" direction.

But the "muscle memory" of most vi users is accustomed to invoking
search by whacking the slash key, not the question mark.  One way
to address this would be for the search to wrap around, but it is
far more common to want to find the most recent command than the
oldest one.

Therefore slash is bound to the most useful search direction, not
to the widget that corresponds by name to the meaning in vi(m).

But sometimes you really do need to search forward, so the "opposite"
keystroke from vi(m) is bound to the opposite search direction, to
avoid having no default foward search binding at all.

Messages sorted by: Reverse Date, Date, Thread, Author