You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2.3 KiB

Vim or Neovim as a Manpager Replacement

vim religion invades the manpages

  • tutorial video: Link

vim as manpager

vim ~/.bashrc or ~/.zshrc
export MANPAGER="/bin/sh -c \"col -b | vim --not-a-term -c 'set ft=man ts=8 nomod nolist noma' -\""

# extra stuff in vimrc
vim ~/.vimrc
set cursorline                       " Highligt the cursor line
set cursorcolumn                     " Highlight the column line
set number                           " Show the line number

neovim as manpager with table of contents

nvim ~/.bashrc or ~/.zshrc
export MANPAGER="nvim +set\ filetype=man -"

if the above doesn't work try the following:
export MANPAGER="nvim -c 'set ft=man' -"

nvim ~/.config/fish/config.fish
set MANPAGER "nvim -c 'set ft=man' -"

The following code snippet does seem to disable the default keybinding gO to toggle the TOC: 
nvim ~/.config/nvim/init.vim
filetype plugin on
syntax on

" manpage with table of contents sidebar with neovim
" https://asciinema.org/a/165076
" add to shellrc: export MANPAGER="nvim +set\ filetype=man -"
augroup manlaunchtoc
    autocmd!
    if has('nvim')
        autocmd FileType man
            \ call man#show_toc() |
            \ setlocal laststatus=0 nonumber norelativenumber |
            \ nnoremap <buffer> l <Enter> |
            \ wincmd H |
            \ vert resize 35 |
            \ wincmd p
    endif
augroup end

references

contact

             _   _     _      _         
  __ _  ___ | |_| |__ | | ___| |_ _   _ 
 / _` |/ _ \| __| '_ \| |/ _ \ __| | | |
| (_| | (_) | |_| |_) | |  __/ |_| |_| |
 \__, |\___/ \__|_.__/|_|\___|\__|\__,_|
 |___/