[vim/vim] termguicolors doesn't work in terminal Vim (#993)

638 views
Skip to first unread message

Alesandar Metodiev

unread,
Aug 21, 2016, 6:13:41 AM8/21/16
to vim/vim

Truecolor works just out of the box within the terminal emulator of my choice - st by suckless. Neovim looks perfect. However, I've recently noticed that :set termguicolors breaks the colors in Vim. I've reproduced the issue without .vimrc by running :termguicolors and then :hi! LineNr ctermfg=red ctermbg=red guifg=red guibg=red or any other highlight group. With truecolor ready colorschemes, such as solarized8 or gotham256, I get only white text over my terminal's default background.

:help

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug 21 2016 12:29:10)
Included patches: 1-2232
Compiled by Arch Linux
Huge version without GUI. Features included (+) or not (-):
+acl +dialog_con +job +mouse_sgr +rightleft +user_commands
+arabic +diff +jumplist -mouse_sysmouse +ruby +vertsplit
+autocmd +digraphs +keymap +mouse_urxvt +scrollbind +virtualedit
-balloon_eval -dnd +lambda +mouse_xterm +signs +visual
-browse -ebcdic +langmap +multi_byte +smartindent +visualextra
++builtin_terms +emacs_tags +libcall +multi_lang +startuptime +viminfo
+byte_offset +eval +linebreak -mzscheme +statusline +vreplace
+channel +ex_extra +lispindent +netbeans_intg -sun_workshop +wildignore
+cindent +extra_search +listcmds +num64 +syntax +wildmenu
+clientserver +farsi +localmap +packages +tag_binary +windows
+clipboard +file_in_path +lua +path_extra +tag_old_static +writebackup
+cmdline_compl +find_in_path +menu +perl -tag_any_white +X11
+cmdline_hist +float +mksession +persistent_undo -tcl +xfontset
+cmdline_info +folding +modify_fname +postscript +termguicolors -xim
+comments -footer +mouse +printer +terminfo -xpm
+conceal +fork() -mouseshape +profile +termresponse +xsmp_interact
+cryptv +gettext +mouse_dec +python +textobjects +xterm_clipboard
+cscope -hangul_input +mouse_gpm -python3 +timers -xterm_save
+cursorbind +iconv -mouse_jsbterm +quickfix +title
+cursorshape +insert_expand +mouse_netterm +reltime -toolbar


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, .

Lifepillar

unread,
Aug 21, 2016, 8:51:17 AM8/21/16
to vim/vim

Did you get that behaviour only with the mentioned color schemes (note that “true-color ready” essentially just means that guibg and guifg are defined also in terminal Vim)? I cannot reproduce what you describe with Vim 7.4 1-2210 and iTerm2. Is it any different with :hi! LineNr guifg=#ff0000 guibg=#ff0000?


You are receiving this because you are subscribed to this thread.

Reply to this email directly, view it on GitHub, or mute the thread.

Lifepillar

unread,
Aug 21, 2016, 8:57:48 AM8/21/16
to vim/vim

Btw, are you running Vim inside tmux? In which case, you should most likely have to set t_8f and t_8b (see :h xterm-true-color).

Alesandar Metodiev

unread,
Aug 22, 2016, 2:08:03 PM8/22/16
to vim/vim

No, the issue occurs outside tmux. Nothing has changed by using a HEX value.

Lifepillar

unread,
Aug 22, 2016, 5:05:34 PM8/22/16
to vim/vim

What if you set t_8f and t_8b anyway as explained in the manual?

Alesandar Metodiev

unread,
Aug 23, 2016, 5:23:39 AM8/23/16
to vim/vim

By applying termguicolors and the following snippet (before a colorscheme has been set):

set t_8f=^[[38;2;%lu;%lu;%lum
set t_8b=^[[48;2;%lu;%lu;%lum

I get only escape sequences drawn on my screen.

K.Takata

unread,
Aug 23, 2016, 5:29:47 AM8/23/16
to vim/vim

You should input actual escape for ^[.
Use <Ctrl-V><Esc> to input actual escape.

Alesandar Metodiev

unread,
Aug 23, 2016, 5:45:47 AM8/23/16
to vim/vim

What exactly do you mean? <C-v><ESC> returns only ^[.

vim-dev ML

unread,
Aug 23, 2016, 5:50:35 AM8/23/16
to vim/vim, vim-dev ML, Your activity
Am 2016-08-23 11:45, schrieb Alesandar Metodiev:
> What exactly do you mean? <C-v><ESC> returns only ^[.

so it is only one char, and not two? That is good.

Can you confirm, you are actually using a terminal application (tmux
version)
that supports true color mode at all? What is your TERM variable set to?

Best,
Christian


You are receiving this because you are subscribed to this thread.

K.Takata

unread,
Aug 23, 2016, 6:05:17 AM8/23/16
to vim/vim, vim-dev ML, Comment

If the ^[ is two characters (^ and [), it's wrong. If it is one character, it's okay.
When you delete the character with backspace, you will find that ^[ is deleted at once.
Please also check :help c_CTRL-V (and :help i_CTRL-V).


You are receiving this because you commented.

Ken Takata

unread,
Aug 23, 2016, 6:11:48 AM8/23/16
to vim_dev
Hi Christian,
(off topic)

2016/8/23 Tue 18:50:35 UTC+9 vim-dev ML wrote:
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub, or mute the thread.

The link "mute the thread" is still here.
I think the link should be removed.

Regards,
Ken Takata

Alesandar Metodiev

unread,
Aug 23, 2016, 9:59:05 AM8/23/16
to vim/vim, vim-dev ML, Mention

@vim-ml, yes ^[ is a single character. I've already said that I'm not running Vim inside tmux, but simply a terminal emulator that has truecolor support (it has been troubleshooted already). I believe that $TERM must be set to st-256color. If tmux has been started, it must be screen-256color. Can't check right now. In any case, my terminal reports that it has truecolor enabled and Neovim works just out of the box.


You are receiving this because you were mentioned.

vim-dev ML

unread,
Aug 23, 2016, 10:03:42 AM8/23/16
to vim/vim, vim-dev ML, Your activity

On Di, 23 Aug 2016, Alesandar Metodiev wrote:

> @vim-ml, yes `^[` is a single character. I've already said that I'm not running Vim inside tmux, but simply a terminal emulator that has truecolor support (it has been troubleshooted already). I believe that `$TERM` must be set to `st-256color`. If tmux has been started, it must be `screen-256color`. Can't check right now. In any case, my terminal reports that it has truecolor enabled and Neovim works just out of the box.

Hm, I think that st as terminal support has only recently been added.
What was your vim version?

Best,
Christian
--
Zukunft ist die Zeit, in der man die ganze Vergangenheit kennen wird.
Solange man die Vergangenheit nur teilweise kennt, lebt man in der
Gegenwart.
-- Gabriel Laub


You are receiving this because you are subscribed to this thread.

Alesandar Metodiev

unread,
Aug 23, 2016, 11:32:44 AM8/23/16
to vim/vim, vim-dev ML, Mention

I think that the suckless community has implemented truecolor in st a few years ago. It's not related to my terminal. The problem also exists in xterm.


You are receiving this because you were mentioned.

Christian Brabandt

unread,
Aug 23, 2016, 2:05:37 PM8/23/16
to vim/vim, vim-dev ML, Mention

Well, for what it's worth, I cannot reproduce the issue with the steps mentioned at the first message. For me, this works. Sorry, for not being able to help.


You are receiving this because you were mentioned.

Francisco Lopes

unread,
Aug 24, 2016, 1:56:10 AM8/24/16
to vim/vim, vim-dev ML, Mention

True colors also works for me both inside as well as outside tmux. I'm using the development version of the xfce4-terminal emulator, which supports true colors. My only issue is with transparent background as mentioned on issue #981. There I also detail how I have correctly setup vim to get true colors.


You are receiving this because you were mentioned.

Benjamin R. Haskell

unread,
Oct 24, 2016, 1:35:54 AM10/24/16
to vim/vim, vim-dev ML, Mention

Just came across this while updating my config to move away from my custom 24bit-color-capable build of Vim. With st 0.7-1 on Arch Linux, and with the latest version from git://git.suckless.org/st (currently: 68bae9c), termguicolors seems to work fine, provided you add the Vim-specific &t_8f and &t_8b terminal settings.

I really hate using raw escapes with :set (as in the comment above), due to the ambiguous ^[-but-really-^[-and-not-^-followed-by-[ that several people tried to explain. Here's what I added to my vimrc (before setting a colorscheme) to get things working:

" set Vim-specific sequences for RGB colors
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"

(The characters after the %s are lowercase Ls.)

FWIW, I tested gotham and gotham256 from https://github.com/whatyouhide/vim-gotham and solarized8_dark and solarized8_dark_high from https://github.com/lifepillar/vim-solarized8. All seemed to produce colors that looked like the examples on vimcolors.com. My $TERM setting is st-256color, ATM.


You are receiving this because you were mentioned.

Alesandar Metodiev

unread,
Dec 4, 2016, 2:57:47 PM12/4/16
to vim/vim, vim-dev ML, Mention

Thanks a lot, @benizi! Your solution has fixed my issue. Can't believe it was that simple...


You are receiving this because you were mentioned.

Alesandar Metodiev

unread,
Dec 4, 2016, 2:57:47 PM12/4/16
to vim/vim, vim-dev ML, Mention

Closed #993.


You are receiving this because you were mentioned.

Wang Shidong

unread,
Mar 28, 2017, 8:59:07 PM3/28/17
to vim/vim, vim-dev ML, Mention

@benizi nice catch. it fix my issue with true colors


You are receiving this because you were mentioned.

ktaherig

unread,
Dec 16, 2018, 5:12:09 AM12/16/18
to vim/vim, vim-dev ML, Mention

I need to thank @benizi for this response. Thanks to you, I finally got my TermGUIColors working! Thank you so much, man!!!


You are receiving this because you were mentioned.

Warwick New

unread,
Dec 9, 2019, 7:05:25 AM12/9/19
to vim/vim, vim-dev ML, Mention

I know this is a junky work around on an old thread but since transparency works once vim has started for some, I added set the highlight command to an auto command on vim enter which works with my gruvbox colorshceme set up.

autocmd VimEnter * hi! Normal guibg=NONE


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.

anogoya

unread,
Apr 11, 2021, 7:43:49 PM4/11/21
to vim/vim, vim-dev ML, Mention

@benizi 2021 Fix still going strong! 👍


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.

Sreehariqwerty

unread,
Aug 4, 2021, 4:54:15 AM8/4/21
to vim/vim, vim-dev ML, Mention

Btw, are you running Vim inside tmux? In which case, you should most likely have to set t_8f and t_8b (see :h xterm-true-color).

Thanks


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.

Cedric Bhihe

unread,
Nov 11, 2022, 6:34:10 PM11/11/22
to vim/vim, vim-dev ML, Mention

FYI, the ugly kludge still works wonders ;-)) with Vim 9.0.813 and Tmux 3.3a on Gnome-Terminal 3.46.4.
It's even referenced in the troubleshooting section of this Archlinux wiki !


Reply to this email directly, view it on GitHub.
You are receiving this because you were mentioned.Message ID: <vim/vim/issues/993/1312265726@github.com>

Reply all
Reply to author
Forward
0 new messages