chiark / gitweb /
dot/zshrc: Fix word motion to match my expectations.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 7 Aug 2017 23:42:46 +0000 (00:42 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Tue, 8 Aug 2017 01:00:25 +0000 (02:00 +0100)
Now `words' (following usual Emacs binding notions) work similar to the
Bash defaults, while `sexps' are whole shell arguments.  This isn't
quite as good as I'd like, but it seems good enough at least for now.

dot/zshrc

index b4992b74cd728c78c94ad330fea6dfa06c316a57..2e86a7dfebd44c5d2a9aa9e507878864543eadab 100644 (file)
--- a/dot/zshrc
+++ b/dot/zshrc
@@ -30,10 +30,40 @@ fi
 ###--------------------------------------------------------------------------
 ### Line editing.
 
-autoload -U select-word-style
-select-word-style bash
 bindkey -e
 
+for w in \
+  forward-word backward-word kill-word backward-kill-word \
+  transpose-words capitalize-word up-case-word down-case-word \
+  delete-whole-word select-word
+do
+  autoload -U $w-match
+  zle -N $w-bash $w-match
+  zle -N $w-shell $w-match
+  zstyle ':zle:*-bash' word-style standard
+  zstyle ':zle:*-bash' skip-whitespace-first true
+  zstyle ':zle:*-bash' word-chars ""
+  zstyle ':zle:*-shell' word-style shell
+  zstyle ':zle:*-shell' skip-whitespace-first false
+done
+
+bindkey "\eb" backward-word-bash
+bindkey "\e^b" backward-word-shell
+bindkey "\ef" forward-word-bash
+bindkey "\e^f" forward-word-shell
+bindkey "\e^?" backward-kill-word-bash
+bindkey "^w" backward-kill-word-shell
+bindkey "\ed" kill-word-bash
+bindkey "\e^d" kill-word-shell
+bindkey "\et" transpose-words-bash
+bindkey "\e^t" transpose-words-shell
+bindkey "\eu" up-case-word-bash
+bindkey "\e^u" up-case-word-shell
+bindkey "\el" up-case-word-bash
+bindkey "\e^l" up-case-word-shell
+bindkey "\ec" capitalize-word-bash
+bindkey "\e^c" capitalize-word-shell
+
 ###--------------------------------------------------------------------------
 ### Completion.