1" Vim plugin for using Vim as manpager. 2" Maintainer: Enno Nagel <[email protected]> 3" Last Change: 2020 Aug 05 4 5command! -nargs=0 MANPAGER call s:ManPager() | delcommand MANPAGER 6 7function! s:ManPager() 8 set nocompatible 9 if exists('+viminfofile') 10 set viminfofile=NONE 11 endif 12 set noswapfile 13 14 setlocal ft=man 15 runtime ftplugin/man.vim 16 setlocal buftype=nofile bufhidden=hide iskeyword+=: modifiable 17 18 " Emulate 'col -b' 19 silent! keepj keepp %s/\v(.)\b\ze\1?//ge 20 21 " Remove ansi sequences 22 silent! keepj keepp %s/\v\e\[%(%(\d;)?\d{1,2})?[mK]//ge 23 24 " Remove empty lines above the header 25 call cursor(1, 1) 26 let n = search(".*(.*)", "c") 27 if n > 1 28 exe "1," . n-1 . "d" 29 endif 30 setlocal nomodified readonly 31 32 syntax on 33endfunction 34