Mercurial > vim
comparison runtime/plugin/manpager.vim @ 13231:167a030448fa
Update runtime files.
commit https://github.com/vim/vim/commit/7254067ee970686cc3ff4a1effc3e49e9192a5c1
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Feb 9 22:00:53 2018 +0100
Update runtime files.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 09 Feb 2018 22:15:07 +0100 |
parents | f690da1b3c04 |
children | 29ec2c198c8d |
comparison
equal
deleted
inserted
replaced
13230:0b201ae05cd3 | 13231:167a030448fa |
---|---|
1 " Vim plugin for using Vim as manpager. | 1 " Vim plugin for using Vim as manpager. |
2 " Maintainer: Enno Nagel <ennonagel+vim@gmail.com> | 2 " Maintainer: Enno Nagel <ennonagel+vim@gmail.com> |
3 " Last Change: 2017 November 07 | 3 " Last Change: 2018 Feb 04 |
4 | 4 |
5 " $MAN_PN is supposed to be set by MANPAGER, see ":help manpager.vim". | 5 command! -nargs=0 MANPAGER call s:ManPager() | delcommand MANPAGER |
6 if empty($MAN_PN) | |
7 finish | |
8 endif | |
9 | 6 |
10 command! -nargs=0 MANPAGER call s:MANPAGER() | delcommand MANPAGER | 7 function! s:ManPager() |
8 set nocompatible | |
9 if exists('+viminfofile') | |
10 set viminfofile=NONE | |
11 endif | |
12 set noswapfile | |
11 | 13 |
12 function! s:MANPAGER() | 14 setlocal ft=man |
13 let page_pattern = '\v\w[-_.:0-9A-Za-z]*' | 15 runtime ftplugin/man.vim |
14 let sec_pattern = '\v\w+%(\+\w+)*' | 16 setlocal buftype=nofile bufhidden=hide iskeyword+=: modifiable |
15 let pagesec_pattern = '\v(' . page_pattern . ')\((' . sec_pattern . ')\)' | |
16 | 17 |
17 if $MAN_PN is '1' | 18 " Emulate 'col -b' |
18 let manpage = tolower(matchstr( getline(nextnonblank(1)), '^' . pagesec_pattern )) | 19 silent keepj keepp %s/\v(.)\b\ze\1?//ge |
19 else | 20 |
20 let manpage = expand($MAN_PN) | 21 " Remove empty lines above the header |
22 call cursor(1, 1) | |
23 let n = search(".*(.*)", "c") | |
24 if n > 1 | |
25 exe "1," . n-1 . "d" | |
21 endif | 26 endif |
27 setlocal nomodified readonly | |
22 | 28 |
23 let page_sec = matchlist(manpage, '^' . pagesec_pattern . '$') | 29 syntax on |
24 | |
25 bwipe! | |
26 | |
27 setlocal filetype=man | |
28 exe 'Man' page_sec[2] page_sec[1] | |
29 endfunction | 30 endfunction |