man/Q/Can I browse man pages by heading, including in nvim or LazyVim?
Can I browse man pages by heading, including in nvim or LazyVim?
- Short answer:
man finds and formats a manual page, then hands the result to a pager. The macOS man program and its usual pager, less, do not expose the page's headings as a navigable hierarchy. Neovim's built-in man-page viewer does: open the page with :Man tmux, then press gO for a table of contents. In the terminal pager
- The installed
/usr/bin/man accepts -P pager; MANPAGER overrides PAGER. Its default is less, whose navigation is text-based: search for an uppercase heading with /^COMMANDS$, then use n and N to move among matches. A broader search such as /^[A-Z][A-Z0-9 /_-]*$ finds many top-level headings. less does not parse those matches into an outline. Answer/Official from OpenBSD man(1) and less(1). - This machine currently sets
MANPAGER to col -bx | bat --language=man --style=plain --paging=always. CLI/Tool/bat supplies highlighting and invokes a pager for scrolling, but it does not add heading-aware navigation.
In Neovim
- From an open editor:
:Man tmux. - From the shell:
nvim +'Man tmux'. - In the man-page buffer,
gO opens a location-list outline. Select an entry and press Enter to jump to it; q closes the outline or man window. On the installed tmux(1) page, Neovim finds the main headings plus many indented command and option entries, so the outline is more detailed than a list of top-level sections. - Put the cursor on a reference such as
printf(3) and press K or Ctrl-] to open that man page; Ctrl-T returns. Answer/Official from Neovim's man-page documentation and gO outline documentation. - For a one-off shell invocation using Neovim as the pager:
MANPAGER='nvim +Man!' MANWIDTH=999 man tmux. MANWIDTH=999 reduces hard wrapping before Neovim receives the formatted page. To make this the default, export those variables in the shell configuration; that would replace the current bat-based MANPAGER pipeline.
In LazyVim
- Best fit: use
:Man tmux followed by gO when hierarchy matters. Keep man tmux with the current bat pager for quick linear reading and text search.