Thank you very much for all the answers. If I may have one more question - hopefully the last one on this topic. ;-)
As I mentioned before, I used a similar function to take care of " and ' characters.
- Pressing a " inserts two of them and places the cursor inside the pair. Pressing an ' works in a similar fashion.
- Pressing a backspace inside the pair ("|" or '|', where | is the cursor) deletes both quotes - the left and the right at the same time.
Now, binding the backspace breaks it for isearch.
zle -N insert-single-quotes _insert_single_quotes
zle -N insert-double-quotes _insert_double_quotes
zle -N remove-quotes _remove_quotes
bindkey "'" insert-single-quotes # " ' "
bindkey '"' insert-double-quotes # ' " '
bindkey "^?" remove-quotes # backspace remove the whole pair
bindkey -M isearch '^?' self-insert # This does NOT restore the original functionality.
Instead of restoring the original functionality (deleting the last char), ^? is just inserted into the searched text.
Best regards,
Peter