0

I see three sets of options for terminal colors on the vim documentation.

The first set of options:

t_AB    set background color (ANSI)         *t_AB* *'t_AB'*
t_AF    set foreground color (ANSI)         *t_AF* *'t_AF'*

The second set of options:

t_Sb    set background color                *t_Sb* *'t_Sb'*
t_Sf    set foreground color                *t_Sf* *'t_Sf'*

The third set of options:

t_RF    request terminal foreground color       *t_RF* *'t_RF'*
t_RB    request terminal background color       *t_RB* *'t_RB'*
t_8f    set foreground color (R, G, B)          *t_8f* *'t_8f'*
t_8b    set background color (R, G, B)          *t_8b* *'t_8b'*

I am somewhat puzzled. Why are there three sets of options, what is the difference between them?

I use vim in a terminal that its type is linux. If I want to set the background color of vim in the terminal, which set of options should I use?

I saw the value of the t_AB option by using the "set termcap" command:

 t_AB=^[[4%p1%dm 

What does "^[[4%p1%dm" mean? What color does it represent?

UPDATE:

I am using the xshell emulation terminal, and its current color scheme is set to "New black", the background color of this color scheme uses a dark gray instead of black. My vim color theme file is my_black.vim , the background color of the vimc window is set to black in my_black.vim ; the code is as follows:

set background=dark
hi Normal    ctermfg=119 ctermbg=Black

When I open the vim window in the xshell terminal, the background color of the vim window is dark gray rather than black that i configured in my_black.vim . The dark gray is the background color of the xshell color theme configuration. The xshell also supports other color schemes: "ANISI colors onBlack","Pastel on black"; The background color of the screens background configured in these color schemes is black, and my color theme file: my_black.vim works fine in these color schemes, but only "New black" does not work.

I hope that my vim color theme file is valid in any color configuration scheme of any terminal program, and is not interfered by the color configuration of the terminal program.

Therefore,I have an idea: first I go to get the background color of the current terminal screen by using the value of t_AB or t_Sb or t_8b option in vimrc, and then customize my vim color theme configuration based on the value of t_AB or t_Sb or t_8b option.

how does set a value to t_AB or t_Sb or t_8b option? What should I do ?

  • What is the environment variable TERM set to? Have you tried to set it to xterm or xterm-256color? – Ralf Mar 25 at 5:26
  • @Ralf TERM variable is : term=linux .I didn't set it to xterm or xterm-256color, I set the term type to 'linux' on xshell. – Shaun Mar 25 at 5:50
  • According to the xshell help How to display colors, they recommend xterm. – Ralf Mar 25 at 5:53
  • @Ralf , Whether using xterm, xterm-256color, or linux, my vim windows can display colors, but I chose to use xshell's "New Black" color theme, which will upset my vim color theme. – Shaun Mar 25 at 7:20
  • From my understanding, Vim knows nothing about the colors actually displayed by the terminal. It just sets color codes, that are known to set certain colors. The terminal could decides to display a different color for this code. (Note: This might be different, when termguicolors is set.) – Ralf Mar 25 at 7:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.