开发者

VIM Unix commands printed in color

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 escape开发者_如何学Pythons.


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.


this one:

:!echo $(tput setaf 1)Hello world$(tput sgr0)

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.


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>


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.


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

execute frawor#Setup('0.0', {'autoload/ansi_esc_echo': '0.0'})
call s:_r.ansi_esc.echo("\e[33mabc")

. Currently it deals only (speaking exclusively about special characters or sequences) with carriage return, backspace (untested), tab, newline, and CSI colors.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜