Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Binding Home and End
- X-seq: zsh-users 14749
- From: "Nadav Har'El" <nyh@xxxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Binding Home and End
- Date: Wed, 27 Jan 2010 18:58:43 +0200
- Hebrew-date: 12 Shevat 5770
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
I wanted to have the "Home" and "End" key do in vi mode the obvious thing
(move to the beginning and end of line). The obvious thing to do was
something like this:
bindkey $terminfo[khome] vi-beginning-of-line
and so on.
Unfortunately it didn't work on xterm. Apparently, the terminfo says that
the home key is ^[OH, while it actually generates ^[[H.
After a long investigation I discovered the reason in this page:
http://www.mpimf-heidelberg.mpg.de/~rohm/computing/mpimf/notes/terminal.html
Apparently, for obscure historic reasons, xterm, like the VT100, has two
"modes" - "cursor mode" and "application mode". Cursor keys in the former
generate escape sequences with "[", and in the latter mode they generate
escape sequences with "O". Editors are *expected* to switch to "application"
mode using the "smkx" terminfo capability when they start, and to go back
to the normal "cursor" mode ("rmkx") when they exit. Since editors are
supposed to do that, they can expect cursor keys to generate the "O" escape
sequences, and this is why the "khome" capability is ^[OH, not ^[[H.
I just checked, and vi (for example) indeed switches to application mode.
I wonder - shouldn't ZLE also switch to application mode and leave this
mode when editing is complete (to run a command)?
And if we don't do that, how do people bind the "khome" and "kend" keys?
How does the default "kcuu1" (cursor up key) work, for example? Do you
perhaps use "cuu1" instead of "kcuu1"? That would be cheating ;-) And
unfortunately, there's no "end" (rather than "kend") capability that I
could use.
Any ideas?
Thanks,
Nadav.
P.S. Is there a particular reason why the "Home" and "End" key shouldn't
be bound by default in vi mode (both in insert and command modes)? They
are very useful, and also work in normal vi (or at least, vim).
--
Nadav Har'El | Wednesday, Jan 27 2010, 13 Shevat 5770
nyh@xxxxxxxxxxxxxxxxxxx |-----------------------------------------
Phone +972-523-790466, ICQ 13349191 |Someone offered you a cute little quote
http://nadav.harel.org.il |for your signature? JUST SAY NO!
Messages sorted by:
Reverse Date,
Date,
Thread,
Author