How to search through flags in the manpages

lessmanregular expression

Whenever I search the manpages, I'm almost always trying to find out what's going on with a specific flag. For example, when searching the man pages for pandoc I was searching the for -f flag. I'm not sure how to say, quickly get to the flag which is here:

OPTIONS
   General options
       -f FORMAT, -r FORMAT, --from=FORMAT, --read=FORMAT

and filter out stuff like:

iconv -t utf-8 input.txt | pandoc | iconv -f utf-8           

or

pandoc -f markdown -t latex hello.txt

I've tried searching for /-f, and I've looked at another post and tried (^|\s)-f($|\s\) but it was invalid. So I'm wondering how do you quickly search less for "only the flag -f"?

Would love your thoughts or some other tool that you use to quickly go through documentation

Best Answer

One reasonably convenient, if not perfect, approach is to rely on the fact that the definition of an option usually involves that option being at the start of a line preceded only by spaces, so you can type:

/^ *-f

If you want to search for a long option, you might find that there's a short option before it, so you could type this instead:

/^ *-.*-from

While it may be possible to get a bit more accurate than this, for interactive use you normally want something quick and easy to remember.

Related Question