简体   繁体   English

vim 中的 termguicolors 使一切变成黑白

[英]termguicolors in vim makes everything black and white

The idea is that by using set termguicolors in Vim, I should get the colorscheme (gruvbox) to look in my terminal ( st , has true color support) exactly like in GVim.这个想法是,通过在 Vim 中使用set termguicolors ,我应该让颜色方案(gruvbox)在我的终端( st ,具有真彩色支持)中看起来就像在 GVim 中一样。 But all I get is white text on black background.但我得到的只是黑色背景上的白色文本。

The part in vimrc which sets the colorscheme: vimrc 中设置颜色方案的部分:

set background=dark
colorscheme gruvbox
set termguicolors

You might read :h xterm-true-color .您可能会阅读:h xterm-true-color

I'm using st as well, and indeed, setting termguicolors gave me black and white colors only.我也在使用st ,实际上,设置termguicolors给了我黑白 colors 。

But by following the advice in the help, I added the following:但是按照帮助中的建议,我添加了以下内容:

let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"

Then colors appeared again.然后colors又出现了。 Hope it can help.希望它可以提供帮助。

Here is the whole excerpt from :h xterm-true-color :以下是:h xterm-true-color的完整摘录:

Vim supports using true colors in the terminal (taken from |highlight-guifg| and |highlight-guibg|), given that the terminal supports this. Vim 支持在终端中使用真正的 colors(取自 |highlight-guifg| 和 |highlight-guibg|),前提是终端支持这一点。 To make this work the 'termguicolors' option needs to be set.要完成这项工作,需要设置 'termguicolors' 选项。 See https://gist.github.com/XVilka/8346728 for a list of terminals that support true colors.有关支持真正 colors 的终端列表,请参阅https: //gist.github.com/XVilka/8346728。

Sometimes setting 'termguicolors' is not enough and one has to set the |t_8f|有时设置 'termguicolors' 是不够的,必须设置 |t_8f| and |t_8b|和 |t_8b| options explicitly.明确的选项。 Default values of these options are "^[[38;2;%lu;%lu;%lum" and "^[[48;2;%lu;%lu;%lum" respectively, but it is only set when $TERM is xterm .这些选项的默认值分别是“^[[38;2;%lu;%lu;%lum”和“^[[48;2;%lu;%lu;%lum”,但只有在$TERMxterm Some terminals accept the same sequences, but with all semicolons replaced by colons (this is actually more compatible, but less widely supported):一些终端接受相同的序列,但所有分号都被冒号替换(这实际上更兼容,但支持较少):

 let &t_8f = "\<Esc>[38:2:%lu:%lu:%lum" let &t_8b = "\<Esc>[48:2:%lu:%lu:%lum"

These options contain printf strings, with |printf()|这些选项包含 printf 字符串,带有 |printf()| (actually, its C equivalent hence l modifier) invoked with the t_ option value and three unsigned long integers that may have any value between 0 and 255 (inclusive) representing red, green and blue colors respectively. (实际上,它的 C 等效项因此l修饰符)使用 t_ 选项值和三个无符号长整数调用,该整数可能具有 0 到 255(含)之间的任何值,分别代表红色、绿色和蓝色 colors。

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

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