[vim colours + iTerm2 colours]

27 views
Skip to first unread message

Maxim Abalenkov

unread,
Sep 22, 2020, 9:33:32 AM9/22/20
to vim...@googlegroups.com
Dear all,

How are you? Potentially, I have another very simple question for you, vim experts. My usual working environment is Vim running in an iTerm2 session. I tend to use both vim colours and iTerm2 colour scheme. If I understand correctly, the resulting colours that I see are a mixture of both Vim and iTerm2 colour profiles superimposed. Therefore, my question is how do I tell Vim to use only Vim colour settings and ignore the iTerm2 colours? Thank you very much and have a productive day ahead!

Best wishes,
Maxim

Maxim Abalenkov \\ maxim.a...@gmail.com
+44 7 486 486 505 \\ http://mabalenk.gitlab.io

Lifepillar

unread,
Sep 23, 2020, 2:38:15 PM9/23/20
to vim...@googlegroups.com
On 2020-09-22, Maxim Abalenkov <maxim.a...@gmail.com> wrote:
> Dear all,
>
> How are you? Potentially, I have another very simple question for you,
> vim experts. My usual working environment is Vim running in an iTerm2
> session. I tend to use both vim colours and iTerm2 colour scheme. If
> I understand correctly, the resulting colours that I see are a mixture
> of both Vim and iTerm2 colour profiles superimposed. Therefore, my
> question is how do I tell Vim to use only Vim colour settings and
> ignore the iTerm2 colours? Thank you very much and have a productive
> day ahead!

Does

:set termguicolors

solve your problem?

Life.

Maxim Abalenkov

unread,
Sep 23, 2020, 2:50:07 PM9/23/20
to vim...@googlegroups.com
Thank you for your reply. I will check. I'm not certain about the "gui" part of the command. I'm not using Gvim.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/rkg4m0%24944%241%40ciao.gmane.io.

Grant Taylor

unread,
Sep 23, 2020, 3:05:30 PM9/23/20
to vim...@googlegroups.com
On 9/22/20 7:33 AM, Maxim Abalenkov wrote:
> I tend to use both vim colours and iTerm2 colour scheme. If I understand
> correctly, the resulting colours that I see are a mixture of both Vim
> and iTerm2 colour profiles superimposed. Therefore, my question is how
> do I tell Vim to use only Vim colour settings and ignore the iTerm2
> colours? Thank you very much and have a productive day ahead!

Doesn't vim just specify the color number / index (0-7 / 0-15 / 0-255)
that it wants used for specific characters and then rely on the terminal
(emulator) to set the actual colors used for any given color number / index?

I don't think there is any (good*) way for vim to know that you're using
iTerm2 and adjust it's behavior accordingly. I think this is all in
iTerm2's control.

*Shell ~> vim may be able to deduce from the TERM environment variable
(and possibly answer back) what the terminal is. But there usually is
not a one-to-one correlation. Further many terminal emulators tend to
lie and say they are a different terminal; ANSI and VT100 are common. I
don't remember what iTerm2 does by default.



--
Grant. . . .
unix || die

Lifepillar

unread,
Sep 24, 2020, 5:05:36 AM9/24/20
to vim...@googlegroups.com
On 2020-09-23, Maxim Abalenkov <maxim.a...@gmail.com> wrote:
> Thank you for your reply. I will check. I'm not certain about the "gui"
> part of the command. I'm not using Gvim.

The termguicolors option is specifically for terminals supporting
millions of colors, such as iTerm2. It tells Vim to use the "gui" color
specifications of the color scheme you are using (as opposed to the
"cterm" color specifications). Provided that your color scheme defines
guifg and guibg colors for each highlight group (and most color schemes
do), Vim will use such colors, independent of which colors your terminal
is set to display. See `:help termguicolors`, `:help highlight-guifg`,
`:help highlight-ctermfg`.

Some terminals define an environment variable called $COLORTERM to
advertise their color capabilities. Although that is not standard or
universal, it works with iTerm2. So, if you put this snippet in your
vimrc:

if has('termguicolors') && $COLORTERM ==# 'truecolor'
set termguicolors
endif

then termguicolors will be set automatically when you open Vim in
iTerm2.

Hope this helps,
Life.

Lifepillar

unread,
Sep 24, 2020, 5:12:13 AM9/24/20
to vim...@googlegroups.com
On 2020-09-23, 'Grant Taylor' via vim_use <vim...@googlegroups.com> wrote:
> On 9/22/20 7:33 AM, Maxim Abalenkov wrote:
>> I tend to use both vim colours and iTerm2 colour scheme. If I understand
>> correctly, the resulting colours that I see are a mixture of both Vim
>> and iTerm2 colour profiles superimposed. Therefore, my question is how
>> do I tell Vim to use only Vim colour settings and ignore the iTerm2
>> colours? Thank you very much and have a productive day ahead!
>
> Doesn't vim just specify the color number / index (0-7 / 0-15 / 0-255)
> that it wants used for specific characters and then rely on the terminal
> (emulator) to set the actual colors used for any given color number / index?

Not when termguicolors is set to 1.

> I don't think there is any (good*) way for vim to know that you're using
> iTerm2 and adjust it's behavior accordingly. I think this is all in
> iTerm2's control.

iTerm2 defines $TERM_PROGRAM to 'iTerm.app' and $LC_TERMINAL to
'iTerm2'.

Life.

Maxim Abalenkov

unread,
Sep 24, 2020, 5:24:55 AM9/24/20
to vim...@googlegroups.com
Dear Life et al.,

Thank you very much for your thorough explanations! Now we are very close to the solution. My end goal is the opposite. I would like to _disable_ iTerm2 colours, when I use Vim. I would like to use _pure_ Vim colour scheme, without the interference or overlap with the iTerm2 colour profile. I think I will need to replace the “set termguicolors” with the “unset termguicolors” in your snippet to reach my goal. Thank you and have a good day ahead!

Lifepillar

unread,
Sep 24, 2020, 12:58:40 PM9/24/20
to vim...@googlegroups.com
On 2020-09-24, Maxim Abalenkov <maxim.a...@gmail.com> wrote:
>
> Thank you very much for your thorough explanations! Now we are very
> close to the solution. My end goal is the opposite. I would like to
> _disable_ iTerm2 colours, when I use Vim. I would like to use _pure_
> Vim colour scheme, without the interference or overlap with the iTerm2
> colour profile. I think I will need to replace the “set termguicolors”
> with the “unset termguicolors” in your snippet to reach my goal. Thank
> you and have a good day ahead!

Every 0/1 option in Vim can be "unset" by prepending "no", e.g.:

:set notermguicolors

With termguicolors disabled, however, you will *not* disable your
terminal colors; rather, the opposite.

I am guessing, because you didn't tell us which color scheme you are
using: your color scheme might be based on ANSI colors (in the range
0-15, or names as in `:help cterm-colors`), in which case the colors you
see necessarily depend on your terminal's settings.

Life.

Reply all
Reply to author
Forward
0 new messages