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