MacVim 命令行窗口文本着色帮助(Rspec 输出)
我正在尝试过渡到 MacVim 进行 ruby 开发。我遇到的难题之一是快速运行规范并轻松获得结果(通过/失败)。
当我运行 :Rake
(或 :!rspec %
)时,它会运行当前文件中的规范。输出显示在命令窗口中。
如果我在常规终端中运行它,我会得到彩色输出。也就是说,点是绿色的,失败是红色的。
在 MacVim 中,我得到这些奇怪的 [32m
和 [0m
标记。这是一个例子:
有关如何解决此问题的任何想法?
I'm trying to transition to MacVim for ruby dev. One of the hangups I have is running specs quickly and getting results (passes/failures) easily.
When I run :Rake
(or :!rspec %
) it runs the specs in the current file. The output is shown in the command window.
If I run this in regular Terminal, I get colored output. That is, the dots are green and the failures are red.
In MacVim, I get these weird [32m
and [0m
tokens. Here's an example:
Any ideas on how to fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Gvim(我认为 Macvim 只是一个品牌名称:))背后没有真正的终端,所以这就是为什么你会得到这些“奇怪”的令牌 - 它们是真正的终端会解释的转义码作为颜色。
正如 michaelmichael 指出的,让 vim 喜欢 ANSI 转义码是很麻烦的。另外,我喜欢他对 vim-rspec 的建议。我将其(https://github.com/dahu/VimTestRunner)拼凑在一起作为轻量级 rspec 测试运行程序。当您运行测试时,它会在 Vim 状态行中显示红色/绿色条。您可以使用
y
仅运行与当前文件关联的 rspec,也可以使用a
运行当前目录中的所有 rspec。欢迎反馈和改进建议。哦,现阶段它还处于阿尔法阶段。温柔一点。 :-)Gvim (and I assume Macvim is just that with a brand-name :) ) doesn't have a real terminal behind it, so that's why you're getting these 'weird' tokens - they are the escape codes a real terminal would interpret as colors.
As michaelmichael points out, getting vim to like ANSI escape codes is bothersome. Also, I like his suggestion of vim-rspec. I cobbled this (https://github.com/dahu/VimTestRunner) together as a lightweight rspec test runner. It shows a red/green bar in your Vim status line when you run the tests. You can run just the rspec associated with the current file using
<leader>y
or all rspecs in the current directory with<leader>a
. Feedback and suggestions for improvement welcome. Oh, and it's quite alpha at this stage. Be gentle. :-)使用 vim-rspec。它会给你你想要的干净、颜色漂亮的 rspec 输出:
顺便说一句,这些都是 ANSI转义序列会弄乱输出。 请参阅此处了解我的问题几周前在 (Mac|g)vim 中查看 ri 文档时询问如何摆脱它们。底线:尝试获得纯文本输出比尝试将 ANSI 转义序列支持硬塞到 Vim 中更容易。
Use vim-rspec. It'll give you the clean, nicely colored rspec output you're after:
BTW, those are ANSI escape sequences messing up the output. See here for a question I asked a few weeks ago about getting rid of them while viewing ri documentation in (Mac|g)vim. Bottom line: it's easier to try to get plain text output than to try and shoehorn support for ANSI escape sequences into Vim.