Zsh Command Line – Shortcut to Delete Spaces and Tabs Around a Point

command linekeyboard shortcutszsh

In emacs, there is this shortcut

M-\
Delete spaces and tabs around point (delete-horizontal-space).

https://www.gnu.org/software/emacs/manual/html_node/emacs/Deletion.html

it also works in bash. I wonder if there is an equivalent in zsh, or how to define one, please?

Best Answer

I don't think there is, but you can always write it yourself as:

delete-horizontal-space() {
  emulate -L zsh
  set -o extendedglob
  LBUFFER=${LBUFFER%%[[:blank:]]##}
  RBUFFER=${RBUFFER##[[:blank:]]##}
}

zle -N delete-horizontal-space
bindkey '\e\\' delete-horizontal-space
Related Question