zsh-users
 help / color / mirror / code / Atom feed
* How do I disable the mode for using j-k keys to scroll through history?
@ 2022-03-15 22:38 Steve Dondley
  2022-03-15 22:46 ` Bart Schaefer
  2022-03-16  0:21 ` Steve Dondley
  0 siblings, 2 replies; 12+ messages in thread
From: Steve Dondley @ 2022-03-15 22:38 UTC (permalink / raw)
  To: Zsh users

I've been using zsh with oh-my-zsh for several months now with vi 
commands. Frequently, the command line seems to "lock up" and become 
unresponsive to input. I chalked it up to some kind of bug, hit ctrl-c, 
and moved on.

I finally just figured out that I had somehow entered some special mode 
that activates the "j" and "k" keys to pull up prev/next commands. 
Through trial and error, I discovered the <esc> key triggers this mode 
and the "s" key gets out of it.

Haven't figured out how to disable this feature. Google has turned up 
nothing useful after 10 min. of searching. Any ideas?


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: How do I disable the mode for using j-k keys to scroll through history?
  2022-03-15 22:38 How do I disable the mode for using j-k keys to scroll through history? Steve Dondley
@ 2022-03-15 22:46 ` Bart Schaefer
  2022-03-15 22:55   ` Steve Dondley
  2022-03-15 23:47   ` Steve Dondley
  2022-03-16  0:21 ` Steve Dondley
  1 sibling, 2 replies; 12+ messages in thread
From: Bart Schaefer @ 2022-03-15 22:46 UTC (permalink / raw)
  To: Steve Dondley; +Cc: Zsh users

On Tue, Mar 15, 2022 at 3:38 PM Steve Dondley <s@dondley.com> wrote:
>
> I finally just figured out that I had somehow entered some special mode
> that activates the "j" and "k" keys to pull up prev/next commands.

You're using vi mode, so ESC enters vi command mode (as opposed to vi
editing aka insert mode), just as would happen if you hit ESC while in
vi itself.

> Through trial and error, I discovered the <esc> key triggers this mode
> and the "s" key gets out of it.

Any of "a", "i", or "s", or in a limited way "c" or "r", would return
you to insert mode, along with o, A, C, I, O, R, and S.

> Haven't figured out how to disable this feature. Google has turned up
> nothing useful after 10 min. of searching. Any ideas?

Are you sure you want to disable it?  Why are you using vi commands if
you never want to be in command mode?


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: How do I disable the mode for using j-k keys to scroll through history?
  2022-03-15 22:46 ` Bart Schaefer
@ 2022-03-15 22:55   ` Steve Dondley
  2022-03-15 22:57     ` Steve Dondley
  2022-03-15 23:24     ` Lawrence Velázquez
  2022-03-15 23:47   ` Steve Dondley
  1 sibling, 2 replies; 12+ messages in thread
From: Steve Dondley @ 2022-03-15 22:55 UTC (permalink / raw)
  To: zsh-users


> 
> Are you sure you want to disable it?  Why are you using vi commands if
> you never want to be in command mode?

Because I want the insert mode commands. I have no idea how I would use 
vi command mode from a command line.  All it seems to do is annoy me 
frequently by somehow getting accidentally triggered. I have no need for 
traversing command history with j-k keys which is all it seems to be 
good for.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: How do I disable the mode for using j-k keys to scroll through history?
  2022-03-15 22:55   ` Steve Dondley
@ 2022-03-15 22:57     ` Steve Dondley
  2022-03-15 23:24       ` Steve Dondley
                         ` (2 more replies)
  2022-03-15 23:24     ` Lawrence Velázquez
  1 sibling, 3 replies; 12+ messages in thread
From: Steve Dondley @ 2022-03-15 22:57 UTC (permalink / raw)
  To: zsh-users

On 2022-03-15 06:55 PM, Steve Dondley wrote:
>> 
>> Are you sure you want to disable it?  Why are you using vi commands if
>> you never want to be in command mode?
> 
> Because I want the insert mode commands. I have no idea how I would
> use vi command mode from a command line.  All it seems to do is annoy
> me frequently by somehow getting accidentally triggered. I have no
> need for traversing command history with j-k keys which is all it
> seems to be good for.

At a minimum, I need to change the bind key for entering command mode so 
it's not accidentally triggered.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: How do I disable the mode for using j-k keys to scroll through history?
  2022-03-15 22:55   ` Steve Dondley
  2022-03-15 22:57     ` Steve Dondley
@ 2022-03-15 23:24     ` Lawrence Velázquez
  1 sibling, 0 replies; 12+ messages in thread
From: Lawrence Velázquez @ 2022-03-15 23:24 UTC (permalink / raw)
  To: Steve Dondley; +Cc: zsh-users

On Tue, Mar 15, 2022, at 6:55 PM, Steve Dondley wrote:
>> 
>> Are you sure you want to disable it?  Why are you using vi commands if
>> you never want to be in command mode?
>
> Because I want the insert mode commands. I have no idea how I would use 
> vi command mode from a command line.

By hitting Esc or C-[ and then using command-mode commands.  Just
like in vi.

> All it seems to do is annoy me 
> frequently by somehow getting accidentally triggered. I have no need for 
> traversing command history with j-k keys which is all it seems to be 
> good for.

Command mode provides basically the full complement of vi operators,
not just j/k.  If you never want vi command mode I don't understand
why you wouldn't want to use the emacs keymap, which by default is
far more powerful than viins.

-- 
vq


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: How do I disable the mode for using j-k keys to scroll through history?
  2022-03-15 22:57     ` Steve Dondley
@ 2022-03-15 23:24       ` Steve Dondley
  2022-03-15 23:25       ` Bart Schaefer
  2022-03-15 23:27       ` Lawrence Velázquez
  2 siblings, 0 replies; 12+ messages in thread
From: Steve Dondley @ 2022-03-15 23:24 UTC (permalink / raw)
  To: zsh-users

OK, figured it out after some trial and error. Google was about worthless on this. I did:

bindkey -M vicmd -r ^C
bindkey ^X^V vi-cmd-mode

Why ^C works for the control key I have no idea. I always thought that was ctrl-c.

> On Mar 15, 2022, at 6:57 PM, Steve Dondley <s@dondley.com> wrote:
> 
> On 2022-03-15 06:55 PM, Steve Dondley wrote:
>>> Are you sure you want to disable it?  Why are you using vi commands if
>>> you never want to be in command mode?
>> Because I want the insert mode commands. I have no idea how I would
>> use vi command mode from a command line.  All it seems to do is annoy
>> me frequently by somehow getting accidentally triggered. I have no
>> need for traversing command history with j-k keys which is all it
>> seems to be good for.
> 
> At a minimum, I need to change the bind key for entering command mode so it's not accidentally triggered.
> 



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: How do I disable the mode for using j-k keys to scroll through history?
  2022-03-15 22:57     ` Steve Dondley
  2022-03-15 23:24       ` Steve Dondley
@ 2022-03-15 23:25       ` Bart Schaefer
  2022-03-15 23:27       ` Lawrence Velázquez
  2 siblings, 0 replies; 12+ messages in thread
From: Bart Schaefer @ 2022-03-15 23:25 UTC (permalink / raw)
  To: Steve Dondley; +Cc: Zsh Users

On Tue, Mar 15, 2022 at 4:02 PM Steve Dondley <s@dondley.com> wrote:
>
> On 2022-03-15 06:55 PM, Steve Dondley wrote:
> >>
> >> Are you sure you want to disable it?  Why are you using vi commands if
> >> you never want to be in command mode?
> >
> > Because I want the insert mode commands.

There is one "insert mode command" that works slightly differently
than emacs mode, and that's ^W for vi-backward-kill-word.
vi-kill-line would work differently, but you'd have to have exited
from and then re-entered insert mode to notice.  (Of course there are
MORE commands in emacs mode, all bound to ctrl+something.)

> > I have no idea how I would
> > use vi command mode from a command line.

Example:  Hit ESC, and then hit "b" twice to move backward two words,
and then hit "cw" to change the word you're on.

Or:  Hit ESC, and then "I" to go to insert something at the beginning
of the command, and then ESC and "A" to go back to appending at the
end.

Do you never move left and right except one character at a time with
the arrow keys, or by deleting?

> At a minimum, I need to change the bind key for entering command mode so
> it's not accidentally triggered.

To see what's bound:
bindkey -M viins

You're interested in anything that's bound to vi-cmd-mode, e.g.:
"^[" vi-cmd-mode

To remove that:
bindkey -M viins -r '^['

To add a different one, in this example two ESC in sequence:
bindkey -M viins '^[^[' vi-cmd-mode


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: How do I disable the mode for using j-k keys to scroll through history?
  2022-03-15 22:57     ` Steve Dondley
  2022-03-15 23:24       ` Steve Dondley
  2022-03-15 23:25       ` Bart Schaefer
@ 2022-03-15 23:27       ` Lawrence Velázquez
  2022-03-15 23:57         ` Steve Dondley
  2 siblings, 1 reply; 12+ messages in thread
From: Lawrence Velázquez @ 2022-03-15 23:27 UTC (permalink / raw)
  To: Steve Dondley; +Cc: zsh-users

On Tue, Mar 15, 2022, at 6:57 PM, Steve Dondley wrote:
> On 2022-03-15 06:55 PM, Steve Dondley wrote:
> At a minimum, I need to change the bind key for entering command mode so 
> it's not accidentally triggered.

To remove the default binding:

    % bindkey -vr '^['

To set a new one -- for example, C-p:

    % bindkey -v '^P' vi-cmd-mode

-- 
vq


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: How do I disable the mode for using j-k keys to scroll through history?
  2022-03-15 22:46 ` Bart Schaefer
  2022-03-15 22:55   ` Steve Dondley
@ 2022-03-15 23:47   ` Steve Dondley
  1 sibling, 0 replies; 12+ messages in thread
From: Steve Dondley @ 2022-03-15 23:47 UTC (permalink / raw)
  To: zsh-users


> You're using vi mode, so ESC enters vi command mode (as opposed to vi
> editing aka insert mode), just as would happen if you hit ESC while in
> vi itself.

Maybe I'm using the terminology wrong, but I would say <esc> takes me to 
"normal" mode and <s-:> takes me to command mode. So, yeah, I do have a 
use for normal but, but only rarely.




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: How do I disable the mode for using j-k keys to scroll through history?
  2022-03-15 23:27       ` Lawrence Velázquez
@ 2022-03-15 23:57         ` Steve Dondley
  2022-03-15 23:59           ` Bart Schaefer
  0 siblings, 1 reply; 12+ messages in thread
From: Steve Dondley @ 2022-03-15 23:57 UTC (permalink / raw)
  To: Lawrence Velázquez; +Cc: zsh-users

On 2022-03-15 07:27 PM, Lawrence Velázquez wrote:
> On Tue, Mar 15, 2022, at 6:57 PM, Steve Dondley wrote:
>> On 2022-03-15 06:55 PM, Steve Dondley wrote:
>> At a minimum, I need to change the bind key for entering command mode 
>> so
>> it's not accidentally triggered.
> 
> To remove the default binding:
> 
>     % bindkey -vr '^['
> 
> To set a new one -- for example, C-p:
> 
>     % bindkey -v '^P' vi-cmd-mode

Yes, this is what finally worked. Thanks! The other way I posted about 
earlier was not actually working.

I've bound to it to '^V' instead, though.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: How do I disable the mode for using j-k keys to scroll through history?
  2022-03-15 23:57         ` Steve Dondley
@ 2022-03-15 23:59           ` Bart Schaefer
  0 siblings, 0 replies; 12+ messages in thread
From: Bart Schaefer @ 2022-03-15 23:59 UTC (permalink / raw)
  To: Steve Dondley; +Cc: Lawrence Velázquez, Zsh Users

On Tue, Mar 15, 2022 at 4:57 PM Steve Dondley <s@dondley.com> wrote:
>
> I've bound to it to '^V' instead, though.

^V is normally bound to vi-quoted-insert, you might not want to replace that.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: How do I disable the mode for using j-k keys to scroll through history?
  2022-03-15 22:38 How do I disable the mode for using j-k keys to scroll through history? Steve Dondley
  2022-03-15 22:46 ` Bart Schaefer
@ 2022-03-16  0:21 ` Steve Dondley
  1 sibling, 0 replies; 12+ messages in thread
From: Steve Dondley @ 2022-03-16  0:21 UTC (permalink / raw)
  To: Zsh users

On 2022-03-15 06:38 PM, Steve Dondley wrote:
> I've been using zsh with oh-my-zsh for several months now with vi
> commands. Frequently, the command line seems to "lock up" and become
> unresponsive to input. I chalked it up to some kind of bug, hit
> ctrl-c, and moved on.
> 
> I finally just figured out that I had somehow entered some special
> mode that activates the "j" and "k" keys to pull up prev/next
> commands. Through trial and error, I discovered the <esc> key triggers
> this mode and the "s" key gets out of it.
> 
> Haven't figured out how to disable this feature. Google has turned up
> nothing useful after 10 min. of searching. Any ideas?

Heh, so it just dawned on me the big cause for all my mental confusion 
was that I considered "insert" mode to be "normal" mode on the command 
line. And then whenever I hit the <esc> key to do "normal" mode 
operations, I actually thought of that as some special "vim" mode and I 
never gave it much thought. I never stopped to realize I was always in 
vim "insert mode" the whole time I was typing into the command line and 
then going to "normal" mode when I hit escape.

And I have my caps lock keys doubles as a control key and escape key and 
I also double tap the caps lock/control key for a hot key. So if i 
mistyped, it would throw me into normal mode without me realizing it.

Anyway, after months of wondering what the hell was going on, mystery 
solved.

Thanks for the hand helping me figure this out.



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-03-16  0:22 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-15 22:38 How do I disable the mode for using j-k keys to scroll through history? Steve Dondley
2022-03-15 22:46 ` Bart Schaefer
2022-03-15 22:55   ` Steve Dondley
2022-03-15 22:57     ` Steve Dondley
2022-03-15 23:24       ` Steve Dondley
2022-03-15 23:25       ` Bart Schaefer
2022-03-15 23:27       ` Lawrence Velázquez
2022-03-15 23:57         ` Steve Dondley
2022-03-15 23:59           ` Bart Schaefer
2022-03-15 23:24     ` Lawrence Velázquez
2022-03-15 23:47   ` Steve Dondley
2022-03-16  0:21 ` Steve Dondley

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).