1

I am trying to direct data from manpage to gvim file but it's not properly formatted.

Example:

  • In manpage it is shown as NAME (bold)
  • But in gvim its printed as N^HNA^HAM^HME^HE.
  • Similarly for SYNTAX it prints S^HSY^HYN^HNT^HTA^HAX^HX.
  • You can notice additional letter after(or before) ^H.

Please suggest how to correct this.
Also suggest if there is any other way of re-directing, so that it keeps the formatting intact.

  • 3
    Unix and gvim are not file formats: one is an OS standard and the other an editor. Can you clarify (1) the exact steps you take to see the differences; (2) where the file comes from; and (3) what you mean by direct data from unix to gvim? I’ve seen similar things in man pages before for bolding effects. – D. Ben Knoble Jun 10 at 14:07
  • Hello D.BenKnoble, sorry for not providing enough clarification. Your assumption is correct. This issue I am facing is of printing data of 'Manpage' to gvim editor, where it is creating formatting issue. – vikas Jun 11 at 6:33
  • 1
    Shouldn't need an extra command. If you're using GNU tools then why not just man --ascii? (Other implementations should have some another way of dumping plain text if they don't have that flag. ) And, btw, you can't "preserve formatting" in any native way. Vim is a (plain) text editor. – B Layer Jun 11 at 8:37
  • 1
    @vikas try my answer using vim’s native man page environment. – D. Ben Knoble Jun 11 at 12:09
1

Since the OP is dealing directly with manpages, I suggest

:runtime plugin/man.vim

(Which can be put in startup files), followed by

:Man command

Also see help MANPAGER

0

I suppose you are trying to capture the output from a program and open it on gVim... If that's the case, I'm afraid you will need to open the file with the output and then remove those ^H and the repeated character that follows it.

%s/\v(.)^H\1/\1/g

Where:

%s/ substitute in all lines:

\v uses very magic mode (see :help /magic)

(.)^H\1 searchs for one character followed by ^H and then by itself again (a^Ha, for example); note that in order to enter ^H you need to press ^V (or ^Q if you were on a Windows machine) and then ^H

/\1/g replace all the occurrences with the first character

PS: A long time ago, in order to print bold characters you would need to print it, than send a backspace and print it again; well, ^H is that backspace character.

  • Indeed, the man and manpager plugin files that ship with vim do something similar – D. Ben Knoble Jun 10 at 18:02
  • Hello João A. Toledo. Thanks a lot for your input. Your assumption is on point. But command you provided is not working. Error reported is "Pattern not found \v(.)^H\1 ". – vikas Jun 11 at 6:40
  • Good to know that you solved your problem in another way. Regarding the fact that it didn't find the pattern: maybe you didn't entered ^H by pressing Ctrl+V and then Ctrl+H? – João A. Toledo Jun 11 at 13:22
0

I got the solution.

man <command> | col -b > <file>

This command dumps the file without ^H and one extra character.
Drawback: bold letters are not bold, but at-least gvim file is now readable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.