From e04564d52880b39032ca6a1841a48138db185aec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 4 Aug 2020 17:13:22 +0200 Subject: [PATCH] lib: add CTRL-backspace and CTRL-delete to delete whole words MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #7609 Closes #8191 Co-authored-by: Michal Grňo --- lib/key-bindings.zsh | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/key-bindings.zsh b/lib/key-bindings.zsh index 10053f6f3099..ac1adf2e7038 100644 --- a/lib/key-bindings.zsh +++ b/lib/key-bindings.zsh @@ -71,17 +71,33 @@ if [[ -n "${terminfo[kcbt]}" ]]; then fi # [Backspace] - delete backward -bindkey '^?' backward-delete-char +bindkey -M emacs '^?' backward-delete-char +bindkey -M viins '^?' backward-delete-char +bindkey -M vicmd '^?' backward-delete-char # [Delete] - delete forward if [[ -n "${terminfo[kdch1]}" ]]; then bindkey -M emacs "${terminfo[kdch1]}" delete-char bindkey -M viins "${terminfo[kdch1]}" delete-char # [Delete] - delete forward bindkey -M vicmd "${terminfo[kdch1]}" delete-char # [Delete] - delete forward else - bindkey "^[[3~" delete-char - bindkey "^[3;5~" delete-char + bindkey -M emacs "^[[3~" delete-char + bindkey -M viins "^[[3~" delete-char + bindkey -M vicmd "^[[3~" delete-char + + bindkey -M emacs "^[3;5~" delete-char + bindkey -M viins "^[3;5~" delete-char + bindkey -M vicmd "^[3;5~" delete-char fi +# [Ctrl-Backspace] - delete whole backward-word +bindkey -M emacs '^H' backward-kill-word +bindkey -M viins '^H' backward-kill-word +bindkey -M vicmd '^H' backward-kill-word +# [Ctrl-Delete] - delete whole forward-word +bindkey -M emacs '^[[3;5~' kill-word +bindkey -M viins '^[[3;5~' kill-word +bindkey -M vicmd '^[[3;5~' kill-word + # [Ctrl-RightArrow] - move forward one word bindkey -M emacs '^[[1;5C' forward-word bindkey -M viins '^[[1;5C' forward-word @@ -91,11 +107,13 @@ bindkey -M emacs '^[[1;5D' backward-word bindkey -M viins '^[[1;5D' backward-word bindkey -M vicmd '^[[1;5D' backward-word + bindkey '\ew' kill-region # [Esc-w] - Kill from the cursor to the mark bindkey -s '\el' 'ls\n' # [Esc-l] - run command: ls bindkey '^r' history-incremental-search-backward # [Ctrl-r] - Search backward incrementally for a specified string. The string may begin with ^ to anchor the search to the beginning of the line. bindkey ' ' magic-space # [Space] - don't do history expansion + # Edit the current command line in $EDITOR autoload -U edit-command-line zle -N edit-command-line