1
0
Fork 0
mirror of https://github.com/vim/vim synced 2025-03-24 18:55:11 +01:00
vim/runtime/plugin/manpager.vim

37 lines
875 B
VimL
Raw Normal View History

" 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
2018-02-09 22:00:53 +01:00
command! -nargs=0 MANPAGER call s:ManPager() | delcommand MANPAGER
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
endif
2018-02-09 22:00:53 +01:00
set noswapfile
2018-02-09 22:00:53 +01:00
setlocal ft=man
runtime ftplugin/man.vim
setlocal buftype=nofile bufhidden=hide iskeyword+=: modifiable
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
2018-02-09 22:00:53 +01:00
syntax on
endfunction