2016-04-30 14:15:54 +02:00
|
|
|
" Vim plugin for using Vim as manpager.
|
|
|
|
" Maintainer: Enno Nagel <ennonagel+vim@gmail.com>
|
2022-06-06 20:52:59 +01:00
|
|
|
" Last Change: 2022 Jun 05
|
2016-04-30 14:15:54 +02:00
|
|
|
|
2018-02-09 22:00:53 +01:00
|
|
|
command! -nargs=0 MANPAGER call s:ManPager() | delcommand MANPAGER
|
2016-04-30 14:15:54 +02:00
|
|
|
|
2022-06-06 20:52:59 +01:00
|
|
|
function s:ManPager()
|
|
|
|
" global options, keep these to a minimum to avoid side effects
|
|
|
|
if &compatible
|
|
|
|
set nocompatible
|
|
|
|
endif
|
2018-02-09 22:00:53 +01:00
|
|
|
if exists('+viminfofile')
|
|
|
|
set viminfofile=NONE
|
2016-04-30 14:15:54 +02:00
|
|
|
endif
|
2018-02-09 22:00:53 +01:00
|
|
|
set noswapfile
|
2016-04-30 14:15:54 +02:00
|
|
|
|
2018-02-09 22:00:53 +01:00
|
|
|
setlocal ft=man
|
|
|
|
runtime ftplugin/man.vim
|
|
|
|
setlocal buftype=nofile bufhidden=hide iskeyword+=: modifiable
|
2016-04-30 14:15:54 +02:00
|
|
|
|
2018-02-09 22:00:53 +01:00
|
|
|
" Emulate 'col -b'
|
2021-08-14 21:25:52 +02:00
|
|
|
silent! keepj keepp %s/\v(.)\b\ze\1?//ge
|
|
|
|
|
|
|
|
" Remove ansi sequences
|
|
|
|
silent! keepj keepp %s/\v\e\[%(%(\d;)?\d{1,2})?[mK]//ge
|
2018-02-09 22:00:53 +01:00
|
|
|
|
|
|
|
" Remove empty lines above the header
|
|
|
|
call cursor(1, 1)
|
|
|
|
let n = search(".*(.*)", "c")
|
|
|
|
if n > 1
|
|
|
|
exe "1," . n-1 . "d"
|
|
|
|
endif
|
2022-06-06 20:52:59 +01:00
|
|
|
setlocal nomodifiable nomodified readonly nowrite
|
2016-04-30 14:15:54 +02:00
|
|
|
|
2018-02-09 22:00:53 +01:00
|
|
|
syntax on
|
2016-04-30 14:15:54 +02:00
|
|
|
endfunction
|