2

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?

michaelmichael
  • 13,755
  • 7
  • 54
  • 60

2 Answers2

4

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.

mu is too short
  • 426,620
  • 70
  • 833
  • 800
  • Interesting solution! It *sort of* works, but it trades ANSI escape sequences for html tags. For example, the above becomes `Returns the class of Obj, now preferred over Object#type...` – michaelmichael Jan 19 '11 at 15:08
  • 2
    You could try `--format=bs`, that'll use old-school backspace formatting (pipe the output into `cat -v` and you'll see the backspaces) and that'll be easier to filter than ANSI escape sequences. Why there isn't a `--format=plain` for plain text is a mystery. – mu is too short Jan 20 '11 at 07:12
  • i think this is the best bet. the annoying thing is it used to not be a problem in ruby 1.8. seems to be specific to 1.9. also, piping the output to `col -b` removes backspace characters, and is a little cleaner than sed. – michaelmichael Jan 30 '11 at 16:10
  • Nice one with the `col -b`, I think I've forgotten most of the neat little shell scripting tools like that. – mu is too short Jan 30 '11 at 17:14
  • is there any way to scroll thru the output? like less/more do – Cezar Halmagean Feb 09 '11 at 21:15
  • @Cezar: He's viewing the content inside vim so I'm not sure what you mean, I'm more of shell guy than a vim guy anyway. – mu is too short Feb 09 '11 at 21:20
1

These two scripts seem to have been written to address that problem. They don't appear to be perfect solutions. One of them apparently requires a patch to vi, or did at one point. I can't quite tell what the other one does but I think it renders your window, interpreting the codes, when you use a specific command.

There is also some advice on existing vi commands.

See:

DigitalRoss
  • 143,651
  • 25
  • 248
  • 329