4

I open a manpage of some command, and then hit h.

  • In the help, for the search part, what does "spanning files" mean?
  • What are "files" refereed to?

I search a pattern, and hit n to repeat the previous search. I found there is no difference between n and ESC-n.

                          SEARCHING

  /pattern          *  Search forward for (N-th) matching line.
  ?pattern          *  Search backward for (N-th) matching line.
  n                 *  Repeat previous search (for N-th occurrence).
  N                 *  Repeat previous search in reverse direction.
  ESC-n             *  Repeat previous search, **spanning files**.
  ESC-N             *  Repeat previous search, reverse dir. & **spanning files**.
  ESC-u                Undo (toggle) search highlighting.
  &pattern          *  Display only matching lines
5

man displays man pages using a pager - in your case, less. When you press h, you're seeing less's help.

So, as for what "spanning files" means, it's referring to searching across multiple files simultaneously opened in less.

It doesn't apply to the man page use case (since there's only one file opened at the time), but if you did

less file1 file2

at the command line, and then searched for a pattern that occurs in both files with /foo, you could jump between occurrences of the pattern inside file1 using n repeatedly, but it would eventually stop when you hit the last occurrence in the file. At that point, if you were to hit Escn (or usually also Alt+n) it would jump you to the first occurrence of that pattern in file2.

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.