Zsh Mailing List Archive
Messages sorted by:
Re: vi-history-search(forward|backward) vicmd mappings
- X-seq: zsh-workers 37760
- From: Larry Hynes <larry@xxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: vi-history-search(forward|backward) vicmd mappings
- Date: Sun, 24 Jan 2016 11:30:08 +0000 (UTC)
- List-help: <mailto:email@example.com>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:firstname.lastname@example.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <email@example.com> <160123160002.ZM15365@torch.brasslantern.com>
- Reply-to: Larry Hynes <larry@xxxxxxxxxxxxxx>
On 2016-01-24, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> 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.
I fail all of these tests, I'm afraid; I have a lifelong
aversion to 'we've always done it that way'; I generally invoke
history search at the beginning of a command line; and my muscle
memory uses '?' to search backwards and '/' to search forwards.
(And why wouldn't it - it's the correct approach.)
I used to use zsh-history-substring-search but dropped it in
favour of having a smaller and more portable zsh configuration,
and most frequently use history search to find and repeat
often-used commands, beginning from the start of an empty
I would contend that any typical vi(m) user with more than a
casual relationship with the editor would use, by memory, '?'
and '/' to search backwards and forwards, respectively. Or, to
put it another way, so far in this thread I seem to comprise the
representative sample of most vi(m) users. ;-)
I think the crux of the matter, as you've helped me to
understand it, is related to history search 'beginning' at the
end of the history file and the (potentially thorny?) issue of
search wrapping and I understand why 'it is why it is' but - on
balance - I don't agree with the approach.
My final word, which is easily ignored or overruled, is that the
default mappings are just plain 'wrong' and should be changed to
a more 'correct' version. With all that being said, I have no
wish to upset anyone's apple cart or get into a row about it -
and I must acknowledge that my arguments contain a lot of 'I',
'my' and 'me'! - so I deal with it by simply adding:
bindkey -M vicmd '/' vi-history-search-forward bindkey -M
vicmd '?' vi-history-search-backward
to my configuration files.
Thanks for the clarification Bart, I was starting to think it
was all in my head!
Messages sorted by: