【发布时间】:2012-04-01 05:45:39
【问题描述】:
[在 OS X Lion 上使用 MacVim 7.3]
我有一个运行外部命令的 vimscript 函数。它正在正确执行,但输出显示(不需要的)控制字符,例如 [0m、[33m、[36m 和 -1H。 vimscript函数中的相关行是:
exec ":!bundle exec rspec --color " . a:filename
产生:
:!bundle exec rspec --color spec/acceptance/user_logs_in.feature
[33m*[0m
Pending:
[33m User logs in [0m
[36m # the step 'the user "foo@test.host" exists' is not implemented[0m
[36m # [0m
Finished in 0.07121 seconds
[33m1 example, 0 failures, 1 pending[0m
这是来自终端的相同命令和输出的样子,这就是我希望它在 vim 中显示的方式:
$ bundle exec rspec --color spec/acceptance/user_logs_in.feature
*
Pending:
User logs in
# the step 'the user "foo@test.host" exists' is not implemented
#
Finished in 0.1161 seconds
1 example, 0 failures, 1 pending
此外,每当我执行外部命令时,vim 都会在它之后立即显示-1H。例如,如果我输入:
:ls<return>
我明白了:
:ls-1H
<rest of the output is as expected>
关于隐藏这些控制字符和-1H的任何想法。
(免责声明:我对 vim 很陌生,所以请不要假设我有太多的背景知识。)
谢谢。
2012 年 3 月 31 日下午 17:32 更新
Sam Goldman 的正确:MacVim 不知道如何显示颜色,所以它输出颜色代码。
我已经切换到终端 vim(它支持颜色,至少使用 iTerm),但是使用 MacVim 附带的 vim 版本,它是最新的并且编译时支持 ruby(其中其他事情)。最简单的方法是:
brew install macvim --override-system-vim
【问题讨论】:
标签: vim