zsh-workers
 help / color / mirror / code / Atom feed
From: Larry Hynes <larry@larryhynes.com>
To: zsh-workers@zsh.org
Subject: Re: vi-history-search(forward|backward) vicmd mappings
Date: Sun, 24 Jan 2016 11:30:08 +0000 (UTC)	[thread overview]
Message-ID: <n82cjv$dld$1@ger.gmane.org> (raw)
In-Reply-To: <160123160002.ZM15365@torch.brasslantern.com>

On 2016-01-24, Bart Schaefer <schaefer@brasslantern.com> 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[1] 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
command line.

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!

[1] https://github.com/zsh-users/zsh-history-substring-search


  reply	other threads:[~2016-01-24 11:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-23 23:30 Larry Hynes
2016-01-24  0:00 ` Bart Schaefer
2016-01-24 11:30   ` Larry Hynes [this message]
2016-01-24 18:41     ` Bart Schaefer
2016-01-29  3:30       ` Larry Hynes

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='n82cjv$dld$1@ger.gmane.org' \
    --to=larry@larryhynes.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).