在(Mac)中查看ri时摆脱ANSI转义字符 [英] Getting rid of ANSI escape characters when viewing ri in (Mac)Vim

查看:118
本文介绍了在(Mac)中查看ri时摆脱ANSI转义字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在查看gvim和MacVim中的ri文档时遇到了麻烦(两者都尝试过) .例如,终端中$ri class的以下ri片段如下所示:

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:

现在返回 obj 的类 优先于 Object#type

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

这在gvim中:

返回[4mobj [m,现在比[7mObject#type [m,

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

能够在gvim中引用清晰的ri文档真是太好了.关于从哪里开始寻求解决此问题的任何想法?

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

推荐答案

尝试像这样运行ri:

ri --format=rdoc

AFAIK,rdoc格式为纯文本,因此您不必过滤掉ANSI转义序列.

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

您可以通过制作如下的shell脚本来获得真实的"纯文本:

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

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

^H是原始的 Ctrl-H (或任何适合您的退格键)的地方,然后调用该Shell脚本而不是ri.

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

这篇关于在(Mac)中查看ri时摆脱ANSI转义字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆