vimtricks.wiki Concise Vim tricks, one at a time.

How do I read man pages inside Neovim with syntax highlighting and tag navigation?

Answer

:Man {name}

Explanation

Neovim ships with a built-in :Man command (the man.lua ftplugin) that opens manual pages directly in a buffer. Unlike shelling out with :!man cmd, the Neovim :Man integration provides syntax highlighting, <C-]> cross-reference navigation to jump to linked man pages, and full integration with the jump list so you can navigate back with <C-o>.

How it works

  • :Man grep opens the grep(1) man page in a new split
  • :Man 3 printf opens the C library printf man page from section 3
  • Inside the man buffer, <C-]> on a highlighted cross-reference jumps to that man page
  • <C-t> or <C-o> navigate back through the man page history
  • q closes the man page buffer

Example

:Man git-rebase
:Man 5 crontab
:Man 2 open

For the section-prefixed form, the section number comes before the name.

Tips

  • Use :vertical Man {name} to open the man page in a vertical split instead of horizontal
  • Set Neovim as your system-wide man pager by adding this to your shell profile:
    export MANPAGER='nvim +Man!'
    
    Then man grep in the terminal opens directly in Neovim
  • K in Normal mode runs :Man on the word under the cursor (useful in shell scripts and C files)

Next

How do I make Neovim restore the scroll position when navigating back through the jump list?