Search code examples
vim

Vim opening terminal with different profile than the default


I 'm working on MacOS Catalina and I am using vim 8.2

The only profile set up in my iterm2 is the Default one.

enter image description here

which has been set up to used a slightly customized solarized theme as depicted below

enter image description here

I am now opening vim (which has also been set up to use its counterpart solarized colorscheme)

enter image description here

My question is, why when I am opening the :terminal in vim, this opens in black background (I don't think there even exists a profile with such setting)

enter image description here


Solution

  • This will happen when you have Vim running with 'termguicolors' on. (You can confirm it and see where it's being enabled with :verb set tgc?.) Same as when running in a GUI (not the terminal), it will tell Vim to use 24-bit colors, and use the color scheme full RGB color specifications, rather than use the terminal color palette.

    In that situations, Vim's colors get completely detached from those of the terminal where Vim is running, so Vim's built-in terminal no longer has access to the actual terminal colors.

    You can set specific colors to use in Vim's built-in terminal with the g:terminal_ansi_colors variable (see :help g:terminal_ansi_colors for details.)

    Alternatively, disabling 'termguicolors' should work as well. Assuming the Vim color scheme has been built in a way that will use the terminal color scheme to reproduce the same colors, it might not have other side effects in how Vim colors otherwise look.