Comment Comment by drw More flexible would be a double-quote-region widget which can be applied arbitrarily to any region of a command line: emulate -L zsh if [[ "$REGION_ACTIVE" -eq 0 ]]; then return fi if [[ "$MARK" -le "$CURSOR" ]]; then left_region_bound="$MARK" right_region_bound="$CURSOR" else left_region_bound="$CURSOR" right_region_bound="$MARK" fi length_region="$((right_region_bound - left_region_bound))" before_region="${BUFFER:0:$left_region_bound}" region="${BUFFER:$left_region_bound:$length_region}" after_region="${BUFFER:$right_region_bound}" quoted_region="${(qqq)region}" cursor_offset="$(($#quoted_region - $#region))" BUFFER="$before_region$quoted_region$after_region" CURSOR="$((CURSOR + cursor_offset))" REGION_ACTIVE=0 bind with eg zle -N double-quote-region bindkey '\e"' double-quote-region parent drw 4 years ago