Zsh Mailing List Archive
Messages sorted by:
Re: bug report
- X-seq: zsh-workers 33191
- From: Frank Terbeck <ft@xxxxxxxxxxxxxxxxxxx>
- To: Mica Chimera <micachimera@xxxxxxxxx>
- Subject: Re: bug report
- Date: Wed, 17 Sep 2014 03:08:27 +0200
- Cc: zsh-workers@xxxxxxx
- In-reply-to: <CABMqv67mNGb3wek4QBO8vqU4R=JUp9LE65VHePCgLV4DE_xJGQ@mail.gmail.com> (Mica Chimera's message of "Tue, 16 Sep 2014 19:26:01 -0500")
- 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: <CABMqv67mNGb3wek4QBO8vqU4R=JUp9LE65VHePCgLV4DE_xJGQ@mail.gmail.com>
Mica Chimera wrote:
> Strange behavior when using vi editor mode.
> It goes something like this, with "|" being cursor:
> %: bindkey -v
> %: mv /some/file /some/other/file
> commands: <ESC>Bi
> %: mv /some/file |/some/other/file
> At this point I can type in new stuff just fine, and <BS> up to the point
> where I reentered insert mode, but anything earlier than that beeps and
> doesn't delete.
This is the behaviour of the original vi, which vi-mode is loosely based
on. You can always rebind to ‘backward-delete-char’ if you prefer.
> Stranger still is when I <DEL>
> %: mv /some/file /SOME/OTH|er/file
> Changes it to caps.
This on the other hand is just a lack of understanding of how terminals
work. I'll try to give a brief explanation of what's going on: Special
keys, like DELETE or INSERT or the PageUp key, are encoded by terminals
as so called escape sequences. (All of this stems from the fact that
"terminals" are actually programs that emulate ancient hardware that
exchanged characters with a host via serial links. Colours, for example,
are encoded by escape sequences as well.) In my terminal, pressing the
DELETE key sends four bytes, namely:
ESC [ 3 ~
If that sequence is not bound to a widget (which it is not by default),
ZLE (zsh's line editor) executes the actions associated with the
individual characters. ESC would change back to normal mode; [ would do
nothing by default; and "3 ~" would toggle the capitalisation of the
next three characters.
That would be the case with you, as well. Only that there appears to be
a larger integer in front of the tilde.
Like I said "If that sequence is not bound to a widget". You can bind it
to a widget, like this:
bindkey '^[[3~' delete-char
But the problem with that is, that different terminals use different
sequences for this kind of stuff.
Debian's new zsh packages include a few lines of configuration code that
bind a few common special keys to widgets automatically by looking at
the terminal's terminfo database entry¹. If you're interested, the code
And the lines you would be looking for are the ones from line 18 up to
and including line 91.
You could fix your issue with the BackSpace key in one go by changing
line 54 of that file from
bind2maps viins -- BackSpace vi-backward-delete-char
bind2maps viins -- BackSpace backward-delete-char
(‘bind2maps’ is a simple function defined in that file, that wraps
> I'm using version 5.0.6 and have reproduced the error on multiple x86_64
> machines with default configuration.
> Since no one else seems to be reporting this bug and it's so severe I
> figure it's likely there's something I just don't get. If that's the case
> I'm sorry for all the trouble, but can you let me know what's happening?
No worries. This is quite the common source of confusion.
¹ There are other attempts of handling special keys, like zkbd, but I'm
pretty convinced, that the approach used in that setup is quite robust
for most terminals and the most common of keys. Anything beyond is
usually very much more terminal-specific.
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
-- RFC 1925
Messages sorted by: