Main
2022-02-06

I love the man page system on Linux/Unix and frequently look something up. But one thing drove me crazy: Since the description of flags is written in a new line below the flag, most of the time you have to scroll up again after every search to see the flag you've been searching for. If you don't understand what I mean, search for "symbolic link" in the man page of grep to find the flag -R. Since you're most likely reading man pages with less as pager, there is a way to make this much more convenient: Less has the option -j that will move the matches of a search not in the first line but in the n'th line. Either set MANPAGER='less -j2' (or a higher number), or add the option to the environment variable LESS to enable it everywhere.

en shorterhacks man less

The series Shorter Hacks consists of tips and tricks for Linux nerds. Flags, hacks, and features of everyday tools that you might not know already, but that will enrich your life. I currently have a list of around 40 hacks I collected and plan to publish them roughly weekly. In order for this series to continue, please send me your best trick(s). The focus is not on fancy new tools or extensive rc-file content, but little known features in software most people already use. Send them to michael bei schoenitzer punkt de.
This blog has an Atom-Feed and I plan to also post the Shorter Hacks articles on Mastodon and Twitter.

Creative Commons License "Shorter Hacks 7 better search in man pages" by Michael F. Schönitzer is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.