:q to quit from less and man. Are there other colon-commands in Bash/Zsh?

To quit from man or less, we use :q, like in Vim. But where can I read about this command and probably other similar commands (maybe :w, for example) in Bash or Zsh documentation? help q, help :q, help quit return "Command not found".

Asked By: jsx97


man typically uses less, and you can read about the keyboard shortcuts supported there in man less. Many features in less are based on vi, hence the similarities. (vi also provides a read-only variant, view, which can be used instead of less.)

None of this is handled by your shell, which is why you won’t find relevant information in your shell’s documentation.

Answered By: Stephen Kitt

None of bash, zsh, or cat support :q as a quit command. Commands that start with a : are technically ex like commands.

When you run applications, the applications themselves handle things like this. It may look like man is doing it, but man automatically runs a pager (pick one by setting environment variable PAGER) which by default on most linux systems is less. (Older systems used more .) You can get a list of keys with man less or by typing the h key when in the pager. (I think almost all support the h help key.)

Note that in vi commands activated with : are actually from the older ex command line oriented editor. When vi ("visual") was created, the ex editor was embedded in it because it handles some advanced things that the keystroke driven vi could not do.

In turn, ex was somewhat based on the even older ed. The ex and vi commands typically shared a binary, and now ex and vim share a binary (and probably vi too). The ed editor is still available on many unix like systems.

Note that less actually supports using the exit keys and commands (and several other simple action sequences) from multiple editors, including not just ex but also vi and emacs. Likely this is to make people with muscle memory happy.

Answered By: user10489
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.