如何让Vim对Cygwin显示正确的颜色? [英] How to get Vim on Cygwin to display right colors?

查看:753
本文介绍了如何让Vim对Cygwin显示正确的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Cygwin上使用Vim。我试图使用沙漠色方案。在gVim中,它如下所示:



http ://i.stack.imgur.com/FNaVa.png



但在我的MinTTY终端中,它看起来像这样:



http://i.stack.imgur.com/dYPkF.png



有办法修复吗?



我的TERM变量设置为xterm-256color 。此外,我已经添加t_Co = 256到我的.vimrc文件。但它没有帮助。



我已经找到了一些解决方案。我可以修复它使用CSApprox / guicolorscheme插件。

解决方案

尝试从 vim 的沙漠颜色方案定义中获取RGB 0xRRGGBB 值,并将它们插入MinTTY使用下面的技术。然后,您可以重写配色方案(可能在以新名称进行复制后,首先)以使用新定义的颜色(在0-15范围内)。您可以将 echo 命令放入 .bashrc ,以便为每个打开的MinTTY终端设置它们。 / p>

http://代码。 google.com/p/mintty/wiki/Tips



更改颜色



可以在选项对话框中更改默认的前景,背景和光标颜色,或者通过在配置文件或命令行中指定ForegroundColour,BackgroundColour和CursorColour设置。



然而,它们也可以在终端内使用xterm控制序列来改变,例如:

  echo -ne'\e] 10;#000000\a'#Black foreground 
echo -ne'\e] 11;#C0C0C0\a'#浅灰色背景
echo -ne'\e] 12;#00FF00\a'#绿色光标

在mintty ,还可以使用逗号分隔的十进制符号来指定RGB颜色值,例如255,0,0而不是红色的#FF0000。目前不支持X11颜色名称。



16个ANSI颜色可以在配置文件中或在命令行中使用诸如Blue或BoldMagenta等设置来设置。这些记录在手册的配置部分。也可以使用xterm控制序列更改它们。这里他们使用默认值:

  echo -ne'\e] 4; 0;#000000 \a' #black 
echo -ne'\e] 4; 1;#BF0000\a'#red
echo -ne'\e] 4; 2;#00BF00\a'#green
echo -ne'\e] 4; 3;#BFBF00\a'#yellow
echo -ne'\e] 4; 4;#0000BF\a'#blue
echo -ne'\e] 4; 5;#BF00BF\a'#magenta
echo -ne'\e] 4; 6;#00BFBF\a'#cyan
echo -ne'\e] 4; 7;#BFBFBF\a'#white(light grey really)
echo -ne'\e] 4; 8;#404040\a'#bold black (即深灰色)
echo -ne'\e] 4; 9;#FF4040\a'#bold red
echo -ne'\e] 4; 10;#40FF40\ a##bold green
echo -ne'\e] 4; 11;#FFFF40\a'#bold yellow
echo -ne'\e] 4; 12;#6060FF\ a##bold blue
echo -ne'\e] 4; 13;#FF40FF\a'#bold magenta
echo -ne'\e] 4; 14;#40FFFF\ a'#bold cyan
echo -ne'\e] 4; 15;#FFFFFF\a'#bold white


I am using Vim on Cygwin. And I am trying to use desert color scheme. In gVim it looks like this:

http://i.stack.imgur.com/FNaVa.png

But in my MinTTY terminal it looks like this:

http://i.stack.imgur.com/dYPkF.png

Is there way to fix it?

My TERM variable is set to xterm-256color. Also, I have added t_Co=256 to my .vimrc file. But it doesn't help.

P.S. I have already found some solution. I can fix it using CSApprox/guicolorscheme plugins. However, is there way to fix it not using plugins?

解决方案

Try grabbing the RGB 0xRRGGBB values for the colors from inside the desert color scheme definition for vim and plugging them into MinTTY using the technique below. Then you can rewrite the color scheme (probably after making a copy under a new name, first) to use your newly defined colors (in the 0-15 range). You can put the echo commands into your .bashrc so they will be setup for every MinTTY terminal that is opened.

From http://code.google.com/p/mintty/wiki/Tips:

Changing colours

The default foreground, background and cursor colours can be changed in the options dialog, or by specifying the ForegroundColour, BackgroundColour and CursorColour settings in the configuration file or on the command line.

However, they can also be changed from within the terminal using the xterm control sequences for this purpose, for example:

echo -ne '\e]10;#000000\a'  # Black foreground
echo -ne '\e]11;#C0C0C0\a'  # Light gray background
echo -ne '\e]12;#00FF00\a'  # Green cursor

In mintty, the RGB colour values can also be specified using a comma-separated decimal notation, for example 255,0,0 instead of #FF0000 for red. X11 colour names are not currently supported though.

The 16 ANSI colours can be set in the configuration file or on the command line using settings such as Blue or BoldMagenta. These are documented in the configuration section of the manual. They can also be changed using xterm control sequences. Here they are with their default values:

echo -ne '\e]4;0;#000000\a'   # black
echo -ne '\e]4;1;#BF0000\a'   # red
echo -ne '\e]4;2;#00BF00\a'   # green
echo -ne '\e]4;3;#BFBF00\a'   # yellow
echo -ne '\e]4;4;#0000BF\a'   # blue
echo -ne '\e]4;5;#BF00BF\a'   # magenta
echo -ne '\e]4;6;#00BFBF\a'   # cyan
echo -ne '\e]4;7;#BFBFBF\a'   # white (light grey really)
echo -ne '\e]4;8;#404040\a'   # bold black (i.e. dark grey)
echo -ne '\e]4;9;#FF4040\a'   # bold red
echo -ne '\e]4;10;#40FF40\a'  # bold green
echo -ne '\e]4;11;#FFFF40\a'  # bold yellow
echo -ne '\e]4;12;#6060FF\a'  # bold blue
echo -ne '\e]4;13;#FF40FF\a'  # bold magenta
echo -ne '\e]4;14;#40FFFF\a'  # bold cyan
echo -ne '\e]4;15;#FFFFFF\a'  # bold white

这篇关于如何让Vim对Cygwin显示正确的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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