简体   繁体   English

OSX 终端/Vim 语法 Colors

[英]OSX Terminal/Vim Syntax Colors

I've spent a bunch of time going over my Vim and Tmux configurations lately, trying to refine my workflow and I have come across a (small but annoying) problem that is stumping me.最近我花了很多时间检查我的 Vim 和 Tmux 配置,试图改进我的工作流程,但我遇到了一个(小但烦人的)问题,这让我很困扰。 I am currently using OSX, but I have had the same issue with Windows' terminal/powershell.我目前正在使用 OSX,但我在使用 Windows 的终端/powershell 时遇到了同样的问题。

My issue is that I am unable to change the brown color that appears in the default vim syntax highlighting which is used many of the languages that I write in. The color that I am speaking of can be seen in this vim colortest:我的问题是我无法更改默认 vim 语法突出显示中出现的brown ,该语法突出显示用于我编写的许多语言。我所说的颜色可以在这个 vim colortest 中看到:

在此处输入图像描述

In the default OSX terminal (and in powershell) you can set the ANSI colors via terminal preferences, however, the brown color is not included in the GUI configuration options.在默认的 OSX 终端(和 powershell)中,您可以通过终端首选项设置 ANSI colors,但是, brown不包含在 GUI 配置选项中。 This results in some ugly syntax highlighting that does not fit in with my desired color scheme:这会导致一些丑陋的语法突出显示不符合我想要的配色方案:

在此处输入图像描述

My question is, what is the most portable way to change this default color?我的问题是,更改此默认颜色的最便携方法是什么? I would love to be able to do something in my .vimrc that would just work around this ugly color so I don't have to reconfigure colors for any system that I might be on, but I understand this might not be possible.我希望能够在我的.vimrc中做一些可以解决这种丑陋颜色的事情,所以我不必为我可能使用的任何系统重新配置 colors,但我知道这可能是不可能的。 Another route would be changing the syntax highlighting colors, but my investigations into that have so been unfruitful.另一种方法是更改突出显示 colors 的语法,但我对此的调查没有结果。

Thanks!谢谢!

Appedix: Colors selected in OSX profile for screenshots:附录:在 OSX 配置文件中选择的 Colors 用于屏幕截图: 在此处输入图像描述

Sadly, the default Vim colorscheme is not as tidy as one would hope.可悲的是,默认的 Vim 配色方案并不像人们希望的那样整洁。 In this case, Brown is a bit of a "catchall" name that ends up being interpreted differently in different contexts.在这种情况下, Brown是一个有点“笼统”的名字,最终在不同的上下文中被不同地解释。

  • In GUI Vim, Brown refers to the "Brown" in X11's rgb.txt : #A52A2A .在 GUI Vim 中, Brown指的是 X11 的rgb.txt中的“Brown”: #A52A2A
  • In TUI Vim with &t_Co == 256 , you get #af5f00 , AKA 130 in the "xterm palette".在带有&t_Co == 256的 TUI Vim 中,您会在“xterm 调色板”中获得#af5f00 ,AKA 130
  • In TUI Vim with &t_Co == 16 or &t_Co == 8 , you get your terminal palette's "Yellow", AKA 3 .在带有&t_Co == 16&t_Co == 8的 TUI Vim 中,您将获得终端调色板的“黄色”,也就是3

By the looks of it, you seem to be affected by the second case.从外观上看,您似乎受到了第二种情况的影响。

While there exist ways to change the so-called "xterm palette" wholesale, you will have a hard time changing that specific color in a straightforward, non-messy way.虽然存在大量更改所谓的“xterm 调色板”的方法,但您将很难以直接、不混乱的方式更改特定颜色。

What you can do…你可以做什么…

  • Do :set background=dark to force Vim to use a different set of default colors that doesn't include "Brown".执行:set background=dark强制 Vim 使用不包括“棕色”的不同默认 colors 集。
  • Choose a built-in or third-party colorscheme that doesn't use that specific color.选择不使用该特定颜色的内置或第三方配色方案。
  • Override the Statement highlight group as explained in this gist with whatever color you want from the xterm palette .使用您想要的xterm 调色板中的任何颜色覆盖此要点中解释的Statement highlight 组。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM