Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] Bind quasi-default Home, End and Delete keys in built-in keymaps
- X-seq: zsh-workers 40168
- From: Teubel György <tgyurci@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] Bind quasi-default Home, End and Delete keys in built-in keymaps
- Date: Mon, 12 Dec 2016 16:39:33 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id; bh=hllVVIHJAW76gsBQ8CtaqFrzHfzUMAwBdkPHlxy6V+8=; b=l2anKG/I1Q1viQ21R7rTot7wxDrZRdpXFA0sZSLFXiZsRxMYxAlGK55aSbS+ZbK4qR SFJr/Vx+Yyue+pv5X5LKy3OicKmmns9yMzxF1ccJWJi/UgEbuA44411LwRcZlKojyipx PGnCvvgffni4zkYUSdQhyl4jf3ErQ0EOdpTPWK8RzLQyYBfAvqF/Ot8ryvIpMNvqduCf ZhFQN7Ksdkk2K7iIZbiL5VgQ9WOJz//YFifQWmRILwsIWfnPE+3qBdiX1y7MJ3bGW1mo CWkOY42y+Iq0io7SeI9ZoGInvNiaQHo/gNhUsPzMy7qbMZuWLG1hCSKc4gg7RFHw4DBC B5eg==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
Make Home, End and Delete keys work by default as expected by most users.
---
Doc/Zsh/zle.yo | 12 ++++++------
Src/Zle/zle_keymap.c | 11 +++++++++--
2 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo
index d68365b94..4d2c8580c 100644
--- a/Doc/Zsh/zle.yo
+++ b/Doc/Zsh/zle.yo
@@ -1231,12 +1231,12 @@ item(tt(vi-backward-word-end) (unbound) (tt(ge)) (unbound))(
Move to the end of the previous word, vi-style.
)
tindex(beginning-of-line)
-item(tt(beginning-of-line) (tt(^A)) (unbound) (unbound))(
+item(tt(beginning-of-line) (tt(^A) tt(ESC-[1~)) (unbound) (unbound))(
Move to the beginning of the line. If already at the beginning
of the line, move to the beginning of the previous line, if any.
)
tindex(vi-beginning-of-line)
-item(tt(vi-beginning-of-line))(
+item(tt(vi-beginning-of-line) (unbound) (tt(ESC-[1~)) (tt(ESC-[1~)))(
Move to the beginning of the line, without changing lines.
)
tindex(down-line)
@@ -1244,12 +1244,12 @@ item(tt(down-line) (unbound) (unbound) (unbound))(
Move down a line in the buffer.
)
tindex(end-of-line)
-item(tt(end-of-line) (tt(^E)) (unbound) (unbound))(
+item(tt(end-of-line) (tt(^E) tt(ESC-[4~)) (unbound) (unbound))(
Move to the end of the line. If already at the end
of the line, move to the end of the next line, if any.
)
tindex(vi-end-of-line)
-item(tt(vi-end-of-line) (unbound) (tt($)) (unbound))(
+item(tt(vi-end-of-line) (unbound) (tt($) tt(ESC-[4~)) (tt(ESC-[4~)))(
Move to the end of the line.
If an argument is given to this command, the cursor will be moved to
the end of the line (argument - 1) lines down.
@@ -1778,11 +1778,11 @@ from the cursor position to the endpoint of the movement.
If the command is tt(vi-delete), kill the current line.
)
tindex(delete-char)
-item(tt(delete-char))(
+item(tt(delete-char) (tt(ESC-[3~)) (unbound) (unbound))(
Delete the character under the cursor.
)
tindex(vi-delete-char)
-item(tt(vi-delete-char) (unbound) (tt(x)) (unbound))(
+item(tt(vi-delete-char) (unbound) (tt(x) tt(ESC-[3~)) (tt(ESC-[3~)))(
Delete the character under the cursor,
without going past the end of the line.
)
diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c
index 04eb70675..cff044237 100644
--- a/Src/Zle/zle_keymap.c
+++ b/Src/Zle/zle_keymap.c
@@ -1342,11 +1342,15 @@ default_bindings(void)
vimaps[1] = amap;
for (i = 0; i < 2; i++) {
kptr = vimaps[i];
- /* vi command and insert modes: arrow keys */
+ /* vi command and insert modes: arrow keys,
+ * home, end and delete */
add_cursor_key(kptr, TCUPCURSOR, t_uplineorhistory, 'A');
add_cursor_key(kptr, TCDOWNCURSOR, t_downlineorhistory, 'B');
add_cursor_key(kptr, TCLEFTCURSOR, t_vibackwardchar, 'D');
add_cursor_key(kptr, TCRIGHTCURSOR, t_viforwardchar, 'C');
+ bindkey(kptr, "\033[1~", refthingy(t_vibeginningofline), NULL);
+ bindkey(kptr, "\033[4~", refthingy(t_viendofline), NULL);
+ bindkey(kptr, "\033[3~", refthingy(t_videletechar), NULL);
}
vilmaps[0] = oppmap;
vilmaps[1] = vismap;
@@ -1386,11 +1390,14 @@ default_bindings(void)
bindkey(amap, "guu", NULL, "gugu");
bindkey(amap, "gUU", NULL, "gUgU");
- /* emacs mode: arrow keys */
+ /* emacs mode: arrow keys, home, end and delete */
add_cursor_key(emap, TCUPCURSOR, t_uplineorhistory, 'A');
add_cursor_key(emap, TCDOWNCURSOR, t_downlineorhistory, 'B');
add_cursor_key(emap, TCLEFTCURSOR, t_backwardchar, 'D');
add_cursor_key(emap, TCRIGHTCURSOR, t_forwardchar, 'C');
+ bindkey(emap, "\033[1~", refthingy(t_beginningofline), NULL);
+ bindkey(emap, "\033[4~", refthingy(t_endofline), NULL);
+ bindkey(emap, "\033[3~", refthingy(t_deletechar), NULL);
/* emacs mode: ^X sequences */
bindkey(emap, "\30*", refthingy(t_expandword), NULL);
--
2.11.0
Messages sorted by:
Reverse Date,
Date,
Thread,
Author