Does less (or any other lightweight pager I could use as $PAGER) has such a feature?

For example, if I type man bash and then enter /incorporates it doesn't find the word, despite it being right there, in the second paragraph:

       Bash  is  an  sh-compatible  command language interpreter that executes
       commands read from the standard input or from a file.  Bash also incor-
       porates useful features from the Korn and C shells (ksh and csh).

My djvu and pdf viewer "incorporates" such a feature, and probably other document viewers do too. (pdftotext simply re-joins the words, which means that pdftotext file.pdf - | grep pattern may still be more reliable than pdfgrep).

IIRC info (the GNU texinfo docs viewer) just doesn't hyphenate the words, in order to avoid this. While not directly actionable (I'm mostly using less with preformatted files), I would also be interested in any groff/mandoc options/tricks that could inhibit the end-of-line hyphenation.


You can view the original roff source files, where the words will be joined together.

foo ()
    gunzip -c /usr/share/man/man$1/$2.$1.gz | less

Then, e.g.,

foo 7 groff

To my knowledge, less doesn't have this feature. This works with your PDF viewer because it searches through the original non-hyphenated text, not through the displayed text.

less is not aware of the original text. You must ask man to not hyphenate its output:

man --nh bash
  • No, pdf viewers join back hyphenated words when searching, there's no original non-hyphenated text. Believe me -- or check the source code e.g poppler which is used by most Linux pdf viewers. Jun 24 '21 at 17:40
  • But man --nh is good to know, with the remarks that 1. it seems to only work with the man from Linux. 2. it still splits the compound words which are spelt with a "hard" hyphen -- like the "comma-separated" from the 2nd sentence in the "Brace Expansion" section of bash manpage. Jun 24 '21 at 17:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.