Getting rid of ANSI escape characters when viewing ri in (Mac) Vim

I am having trouble viewing the ri documentation in gvim and MacVim (tried this on both). Some ri documents have text decorations that look great when viewed in a terminal window, but include ANSI escape characters when viewed in gvim / MacVim.For example, the following ri from $ri class looks like this in a terminal:

Returns obj class, now object type is preferred #

And this is in gvim:

Returns the class [4mobj [m, now preferred over [7mObject # type [m,

It would be great to be able to reference legible documents in gvim. Any ideas on where to start looking for this?

+2
ruby vim macvim special-characters ri
source share
2 answers

Try running ri as follows:

 ri --format=rdoc 

AFAIK, the rdoc format is plain text, so you don’t have to filter out ANSI escape sequences.

You can probably get the β€œreal” plain text by creating a shell script as follows:

 ri --format=bs $@ | sed 's:.^H::g' 

Where ^H is raw Ctrl-H (or some other backspace for you) then call this shell script instead of ri .

+4
source share

It seems that these two scenarios were written to solve this problem. They are not an ideal solution. One of them, apparently, requires a patch for vi or at some point. I can’t say what the other one is doing, but I think it displays your window, interpreting the codes when you use a specific command.

There are also recommendations for existing vi commands.

Cm:

+1
source share

All Articles