From: "Teubel György" <tgyurci@gmail.com>
To: zsh-workers@zsh.org
Subject: [PATCH] Bind quasi-default Home, End and Delete keys in built-in keymaps
Date: Mon, 12 Dec 2016 16:39:33 +0100 [thread overview]
Message-ID: <20161212153933.4619-1-tgyurci@gmail.com> (raw)
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
next reply other threads:[~2016-12-12 23:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-12 15:39 Teubel György [this message]
2016-12-13 1:27 ` Frank Terbeck
2016-12-13 10:36 ` Teubel György
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161212153933.4619-1-tgyurci@gmail.com \
--to=tgyurci@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).