9

Zsh has a bit of completion-related automation that's nice most of the time: after pressing Tab, a space is inserted automatically (or some other appropriate character such as , inside braces).

I want to keep this feature except in one case: when I type & or | after pressing Tab, I don't want the space to be removed. I prefer the space to be removed on a ;, and I definitely want to suppress the automatically-inserted comma when pressing Tab } in a brace enumeration.

This feature works by default both in the “old” (compctl) and the “new” (compadd) completion systems. I'm only interested in the new system.

How can I tune the automatic suppression of the automatic suffix inserted by completion?

1 Answer 1

10

This feature can be tuned with ZLE_REMOVE_SUFFIX_CHARS and ZLE_SPACE_SUFFIX_CHARS shell parameters.

  • If the ZLE_REMOVE_SUFFIX_CHARS variable is set, it should contain a set of characters that, when typed, will cause automatic suffixes from the completion to be removed. If ZLE_REMOVE_SUFFIX_CHARS is unset, the default behaviour equates to

    ZLE_REMOVE_SUFFIX_CHARS=$' \t\n;&|'
    
  • For characters set in ZLE_SPACE_SUFFIX_CHARS suffices are replaced with a space. It also takes precedence over ZLE_SPACE_SUFFIX_CHARS


So in order to get your desired behaviour, it should be sufficient to set

ZLE_SPACE_SUFFIX_CHARS=$'|&'

It seems that the automatically inserted , in brace enumerations is always removed when typing }.

Although zshparam(1) mentions that certain completion systems may override this behaviour it seems to work just fine with the "new" compsys (you called it compadd)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .