Mercurial > vim
annotate runtime/plugin/manpager.vim @ 30634:f68f43043842
Update runtime files
Commit: https://github.com/vim/vim/commit/f269eabc6c4f5bdcef989cd5b4b95ba8ccaa4d8a
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Oct 3 18:04:35 2022 +0100
Update runtime files
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 03 Oct 2022 19:15:04 +0200 |
parents | 1e9e9d89f0ee |
children | eb2638f278bf |
rev | line source |
---|---|
9037
d07035f84f0d
commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Vim plugin for using Vim as manpager. |
d07035f84f0d
commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 " Maintainer: Enno Nagel <ennonagel+vim@gmail.com> |
30634 | 3 " Last Change: 2022 Sep 30 |
9037
d07035f84f0d
commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 |
29193 | 5 " Set up the current buffer (likely read from stdin) as a manpage |
6 command MANPAGER call s:ManPager() | |
9037
d07035f84f0d
commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 |
29087 | 8 function s:ManPager() |
9 " global options, keep these to a minimum to avoid side effects | |
10 if &compatible | |
11 set nocompatible | |
12 endif | |
13231 | 13 if exists('+viminfofile') |
14 set viminfofile=NONE | |
15 endif | |
29193 | 16 syntax on |
17 | |
18 " Make this an unlisted, readonly scratch buffer | |
19 setlocal buftype=nofile noswapfile bufhidden=hide nobuflisted readonly | |
9037
d07035f84f0d
commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 |
29193 | 21 " Ensure text width matches window width |
22 setlocal foldcolumn& nofoldenable nonumber norelativenumber | |
23 | |
24 " In case Vim was invoked with -M | |
25 setlocal modifiable | |
13231 | 26 |
27 " Emulate 'col -b' | |
25619 | 28 silent! keepj keepp %s/\v(.)\b\ze\1?//ge |
29 | |
30 " Remove ansi sequences | |
31 silent! keepj keepp %s/\v\e\[%(%(\d;)?\d{1,2})?[mK]//ge | |
9037
d07035f84f0d
commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 |
13231 | 33 " Remove empty lines above the header |
34 call cursor(1, 1) | |
35 let n = search(".*(.*)", "c") | |
36 if n > 1 | |
37 exe "1," . n-1 . "d" | |
38 endif | |
29193 | 39 |
40 " Finished preprocessing the buffer, prevent any further modifications | |
41 setlocal nomodified nomodifiable | |
9037
d07035f84f0d
commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
42 |
29193 | 43 " Set filetype to man even if ftplugin is disabled |
30634 | 44 setlocal filetype=man |
29193 | 45 runtime ftplugin/man.vim |
9037
d07035f84f0d
commit https://github.com/vim/vim/commit/b20545f2a718d4f19c3f609fd11c0ca4eff450ce
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
46 endfunction |