VIM Unix 命令以彩色打印
我正在使用 MacVim,我希望以彩色打印 !
命令。例如:
在 bash 中,以下 echo 语句以绿色打印 Hello World(如预期):
$ echo -e "\033[32m Hello World"
Hello World
然而,在 VIM 中,输出不是颜色,并且打印转义码:
:!echo -e "\033[32m Hello World"
[32m Hello World
How can one have VIM (尤其是 MacVim build 57)打印 !
命令的输出并遵循 ANSI 颜色转义。
I'm using MacVim and I would like to have !
commands printed in color. For example:
In bash, the following echo statement prints Hello World in green (as expected):
$ echo -e "\033[32m Hello World"
Hello World
However, in VIM the output is not color, and the escape codes are printed:
:!echo -e "\033[32m Hello World"
[32m Hello World
How can one have VIM (and MacVim build 57 in particular) print the output of !
commands and honour ANSI color escapes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
你不能。但是您可以挂起编辑器并相对快速地转到 shell;
或者您可以使用
Ansi 过滤器
删除转义序列,这样你至少不会看到混乱。You can't. But you can suspend the editor and drop to a shell relatively quickly;
Or you can use
Ansi Filter
to remove the escape sequences so you will at least not see a mess.这一个:
将以彩色打印
Hello world
。不要使用转义序列,而是使用命名的 tput 条目。 (所有时间,不仅在这个例子中)。阅读:
曼特姆信息;男人infocmp; man tput - 了解更多信息。
根据评论我发现这个问题很有趣。
仍在寻找更好的解决方案,但现在找到这个 - http://code.google.com/ p/征服/ 。
允许在 MacVim 的缓冲区内运行彩色命令。
this one:
will print
Hello world
in color.Don't use escape sequences, but named tput entries. (all times, not only in this example). read:
man teminfo; man infocmp; man tput - for more information.
based on comments I found this question very interesting.
Still searching for the better solution, but for now find this one - http://code.google.com/p/conque/ .
Allow run colored commands inside MacVim's buffer.
不知道这是否有帮助,但是在 vim 中运行我的 RSpec 测试可以使用
--color
选项为我提供彩色输出。我使用以下命令内联运行当前规范文件::map ,t :w\|:!rspec --color %
Don't know if this would help, but running my RSpec tests inside vim gives me colored output using the
--color
option. I use the following command to run the current spec file inline::map ,t :w\|:!rspec --color %<cr>
如果您在控制台模式下运行 macvim(vim,而不是 mvim),所有 :!命令被重定向到 shell 并在那里执行。他们采用整个窗口而不是 1/3,并且使用您的控制台恰好具有的任何主题。
但你会得到 ansicolors。
If you run macvim in console mode (vim, not mvim) all :! commands are redirected to the shell and executed there. They take the whole window instead of 1/3 of it, and they use whatever theme your console happens to have.
But you get ansicolors.
你的问题(及其由@avocade完成的弹出窗口)解决了我在aurum插件中进行一些打印时遇到的问题,因此我已经写了(开始写,但最重要的功能已经在这里)ansi_esc_echo 插件。要在您的系统中使用它,您必须安装它,安装 frawor 并执行
.目前它仅处理(专门针对特殊字符或序列)回车、退格(未经测试)、制表符、换行符和 CSI 颜色。
Your question (and its pop up done by @avocade) addressed the issue I have with some printing in my aurum plugin thus I’ve wrote (started to write, but the most significant piece of functionality is already here) the ansi_esc_echo plugin. To use it in your one you must install it, install frawor and do
. Currently it deals only (speaking exclusively about special characters or sequences) with carriage return, backspace (untested), tab, newline, and CSI colors.