9

I'm using 64-bit Vim 8.1.0428 on Windows 10 release 1803.

The Windows 10 console now has 24-bit colours, and Vim 8 has been patched to handle 24-bit colours in the Windows console (i.e. using vim.exe inside cmd.exe not gVim) using termguicolors.

I can get reasonable colours using the Console ColorTool.

However termguicolors appears to make no difference and I cannot tell if a full 24-bit colour display is being used. Changing the Vim colorscheme has no impact, the colours are almost entirely defined by the console colors.

For example the tender colorscheme is definitely 24-bit, but I cannot see how to get it to work with vim.exe in a dos/console prompt.

Does anyone have examples of how they have used termguicolors / 24-bit colorschemes in the Windows console?

Edit: I think I'm more asking is it possible to get a 256 colour colorscheme working in Vim in a DOS prompt? Even though you can choose from a palette of 24-bit colours, you can still only choose 16 of them"

This is what I've achieved so far, you can see the blatant issues with the Airline Theme colours but I'm not so bothered about that, I'm just trying to figure out what impact the termguicolors should have:

enter image description here

Edit: I have used the xterm-color-table.vim plugin to inspect what colours that I do have:

enter image description here

Setting termguicolors changes all colours to white.

It would appear that I have 16 colours. set t_Co=8 reduces the colour palette, where as set t_Co=16 and set t_Co=256 give the same result.

2
  • 3
    You could try defining a highlighting group with different terminal and gui colors. Then looking at the output of :hi you should be able to tell, whether the gui attributes are used (24bit) or only the terminal colors (256 colors) Sep 24, 2018 at 10:34
  • @ChristianBrabandt - I was being an idiot, my path was still pointing to an old version of Vim. With v8.1.428 I've got full 24-bit colours! It's marvellous! Thank you for the work you've being doing on it. See below for my answer.
    – icc97
    Oct 7, 2018 at 20:38

1 Answer 1

10

tl;dr: My path was using the an old Vim version, with v8.1.428 we have full 24-bit glorious colours in Vim in the Windows Console! See below for screenshots.

Err, so there was a basic mistake on my part. I still had my system environment path pointing to my Git SCM installation C:\Program Files\Git\usr\bin (which contains an older version of Vim) and on top of that I had the same directory before my new Vim installation directory of C:\Program Files\vim\vim81 in the user environment path. I should have noticed that the Vim version was incorrect.

Now that I've solved that mistake I've got the following :version:

:version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Sep 22 2018 22:02:51)
MS-Windows 64-bit console version
Included patches: 1-428
Compiled by appveyor@APPVYR-WIN
Huge version without GUI.  Features included (+) or not (-):
+acl                +cryptv             +gettext/dyn        -mouseshape         +scrollbind         +user_commands
+arabic             +cscope             -hangul_input       +multi_byte_ime/dyn +signs              +vartabs
+autocmd            +cursorbind         +iconv/dyn          +multi_lang         +smartindent        +vertsplit
+autochdir          +cursorshape        +insert_expand      +mzscheme/dyn       +startuptime        +virtualedit
+autoservername     +dialog_con         +job                -netbeans_intg      +statusline         +visual
-balloon_eval       +diff               +jumplist           +num64              -sun_workshop       +visualextra
+balloon_eval_term  +digraphs           +keymap             +packages           +syntax             +viminfo
-browse             -dnd                +lambda             +path_extra         +tag_binary         +vreplace
++builtin_terms     -ebcdic             +langmap            +perl/dyn           +tag_old_static     +vtp
+byte_offset        +emacs_tags         +libcall            +persistent_undo    -tag_any_white      +wildignore
+channel            +eval               +linebreak          -postscript         +tcl/dyn            +wildmenu
+cindent            +ex_extra           +lispindent         +printer            +termguicolors      +windows
+clientserver       +extra_search       +listcmds           +profile            +terminal           +writebackup
+clipboard          +farsi              +localmap           +python/dyn         -tgetent            -xfontset
+cmdline_compl      +file_in_path       +lua/dyn            +python3/dyn        -termresponse       -xim
+cmdline_hist       +find_in_path       +menu               +quickfix           +textobjects        -xpm_w32
+cmdline_info       +float              +mksession          +reltime            +timers             -xterm_save
+comments           +folding            +modify_fname       +rightleft          +title
+conceal            -footer             +mouse              +ruby/dyn           -toolbar
   system vimrc file: "$VIM\vimrc"
     user vimrc file: "$HOME\_vimrc"
 2nd user vimrc file: "$HOME\vimfiles\vimrc"
 3rd user vimrc file: "$VIM\_vimrc"
      user exrc file: "$HOME\_exrc"
  2nd user exrc file: "$VIM\_exrc"
       defaults file: "$VIMRUNTIME\defaults.vim"
Compilation: cl -c /W3 /nologo  -I. -Iproto -DHAVE_PATHDEF -DWIN32  -DFEAT_CSCOPE -DFEAT_TERMINAL  -DFEAT_JOB_CHANNEL
-DWINVER=0x0501 -D_WIN32_WINNT=0x0501 /MP -DHAVE_STDINT_H /Ox /GL -DNDEBUG  /Zl /MT -DFEAT_MBYTE_IME -DDYNAMIC_IME -DFEAT_MBYTE -DDYNAMIC_ICONV -DDYNAMIC_GETTEXT -DFEAT_TCL -DDYNAMIC_TCL -DDYNAMIC_TCL_DLL=\"tcl86t.dll\" -DDYNAMIC_TCL_VER=\"8.6\"
-DFEAT_LUA -DDYNAMIC_LUA -DDYNAMIC_LUA_DLL=\"lua53.dll\" -DFEAT_PYTHON -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=\"python27.dll\" -DFEAT_PYTHON3 -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL=\"python37.dll\" -DFEAT_MZSCHEME -I "C:\Program Files\Racket\include" -DMZ_PRECISE_GC -DDYNAMIC_MZSCHEME -DDYNAMIC_MZSCH_DLL=\"libracket3m_a36fs8.dll\" -DDYNAMIC_MZGC_DLL=\"libracket3m_a36fs8.dll\" -DFEAT_PERL -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DDYNAMIC_PERL -DDYNAMIC_PERL_DLL=\"perl528.dll\" -DFEAT_RUBY -DDYNAMIC_RUBY -DDYNAMIC_RUBY_VER=24 -DDYNAMIC_RUBY_DLL=\"x64-msvcrt-ruby240.dll\" -DFEAT_HUGE /Fd.\ObjCULYHTRZAMD64/
/Zi
Linking: link  /nologo /subsystem:console,5.02 /opt:ref /LTCG:STATUS oldnames.lib kernel32.lib advapi32.lib shell32.lib gdi32.lib  comdlg32.lib ole32.lib netapi32.lib uuid.lib /machine:AMD64   libcmt.lib  user32.lib  /nodefaultlib:lua53.lib  /STACK:8388608  /nodefaultlib:python27.lib /nodefaultlib:python37.lib   "C:\Tcl\lib\tclstub86.lib" WSock32.lib /PDB:vim.pdb -debug

Now the magic happens! Running has("termguicolors") returns 1. So set termguicolors in .vimrc works and suddenly the colours of my :AirlineTheme convert to the correct colours. If I set :AirlineTheme solarized, I get AirlineTheme colours that match GVim exactly:

enter image description here

The disappointment is that the main colorscheme solarized colours are now ruined, however setting colorscheme default gets us a reasonable range of colours (this is with solarized set as my console colours).

enter image description here

However I've got tender a 24-bit theme for me to test with. Setting colorscheme tender in my .vimrc gives some lovely omg-Ive-got-real-proper-syntax-highlighting-in-vim-in-dos colours!

enter image description here

enter image description here

Now testing again with xterm-color-table.vim gives a lovely range as I'd hoped it would.

enter image description here

Many thanks to the Windows console team and the people doing the work to get this into Vim.

Edit: Using the vim-solarized8 theme which is optimised for 24-bit terminals I now have full glorious solarized too:

enter image description here

1
  • 1
    I had the same problem and I never thought of checking out the path! I never thought of checking out the path looking at the previous version! Thanks! Aug 1, 2021 at 8:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.