rubyvimspecial-charactersmacvimri

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


I'm having trouble viewing ri documentation within gvim and MacVim (tried it on both) Some of the ri documentation includes text decorations that look fine when viewed in a terminal window, but include ANSI escape characters when viewing in gvim/MacVim. For example, the following ri snippet from $ri class looks like this in the terminal:

Returns the class of obj, now preferred over Object#type

And this in gvim:

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

It'd be great to be able to reference legible ri docs within gvim. Any ideas on where to begin looking to fix this?


Solution

  • Try running ri like this:

    ri --format=rdoc
    

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

    You can probably get "real" plain text by making a shell script like this:

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

    Where ^H is a raw Ctrl-H (or whatever backspace is for you), then call that shell script instead of ri.