1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
## What is `mnpgr`?
`mnpgr` is a tiny TXR Lisp program that allows Vim to be used as a pager for
reading man pages.
It works in such a way that Vim will remember your last position in each
man page (if Vim is configured to remember file positions).
The program handles the backspace-driven overstrikes that indicate italic,
bold and italic+bold text, translating them to a notation which is
colorized by the Vim syntax provided in `mnpgr.vim`. Thus it has accurate
syntax coloring, like what you see `less`.
Because `mngpr` itself resolves the overstrikes, the resulting rendering
in Vim is searchable.
Another benefit of `mnpgr` is that it replaces with a plain ASCII dash
(U+002D) all the nonsense Unicode dashes output by GNU groff.
This is not just esthetics. In some systems, the U+2010 hyphen
seriously corrupts the terminal display, rendering man pages unreadable.
## Installation
The `mnpgr.vim` file goes into your `~/.vim/syntax` directory, which
you have to create if you have never installed custom syntax files.
The [TXR](/cgit/txr) language is required.
You can use the `mnpgr.tl` program interpreted, or compile it to `mnpgr.tlo`.
To use it interpreted, put it somewhere, for instance your personal `~/bin`
directory. Then:
::txt
export MANPAGER=~/bin/mnpgr.tl
Make sure it has execute permissions.
Compiling is recommended if you read large man pages on a very slow machine.
To compile `mnpgr.tl` to `mnpgr.tlo` use:
::txt
txr --compile=mnpgr.tl
Then put the `mnpgr.tlo` into `~/bin` and:
::txt
export MANPAGER=~/bin/mnpgr.tlo
If `mnpgr.tl` has execute permissions, the compiler will propagate that,
otherwise you have to remember to `chmod +x mnpgr.tlo`.
## Why not use `vim +MANPAGER` or other approaches?
This doesn't handle the backspace overstrikes output by `man`; it can
only be used on `man` output that has been stripped of the overstrikes.
That will then not highlight keywords in the text; there is only a half-baked
highlighting that handles section headings and a few other things
Vim can be coaxed into handling backspace overstrikes by tweaks to
the `ctrlh` syntax it comes with.
However, that only makes the emphasized elements look *good*.
They are left unsearchable because the representation with the backspace
overstrikes is retained under the hood.
The `mnpgr` project started as an answer to a
[Unix StackExchange](https://unix.stackexchange.com/questions/758676/open-man-or-info-pages-from-the-same-position-where-you-left-off-last-time)
question, where that was the initial solution.
The question is specifically about saving the last position.
If Vim alone is used as a pager without a shim script between it
and `man`, it will not save the last position.
|