Cmder changes Vim's colors under WSL - vim

I am using Vim under WSL (Ubuntu) and I installed Cmder for the support of unicode.
Also, I downloaded the codedark colorscheme for Vim and under CMD it works perfectly:
But when I open it with Cmder, this is the result:
As you can see, the colors are not the same.
In Cmder, I chose Monokai as my colorscheme in the settings, and if I change it to something else, it changes the colorscheme of Vim too.
Why doesn't Vim override those settings when its on?
How can I make Vim use the same colorscheme under any console?

Why doesn't Vim override those settings when its on?
A console application (such as Vim) is not allowed to access OS graphics API directly. Instead, it talks to the terminal (Cmder), which, in turn, talks to OS.
Your screen has 24-bit colors (16 million), but Cmder provides for Vim only 8 bits (256 colors). Therefore, Vim can choose from only 256 indexes in Cmder's palette, i.e. a subset of some preselected colors (when you choose a colorscheme in terminal, you actually select colors in that palette). As those colors more or less differ from original codedark scheme, the resulting picture looks different too.
How can I make Vim use the same colorscheme under any console?
Make sure your terminal offers a proper palette. Or switch both terminal and Vim to TrueColor mode. For Vim, it requires setting an option termguicolors on. For Cmder, I'm not really sure, but ConEmu, which Cmder is based on, does suppot TrueColor, so you can make a try.

Related

WSL: Installed colorscheme for terminal vim not working properly

I am a fairly new user of WSL and vim, and I wanted to install a new colorscheme for terminal vim. I do the standard steps: Create a ~/.vim/colors directory, then move the theme.vim files there. And when I open vim I can select them with :colorscheme, but the theme I get is entirely different from the one I installed. I have tried three different themes now and none of them have worked as expected.
Anyone one here knows what the cause of this could be?
Tl;dr: make sure the colorscheme fits your environment.
Vim colorschemes can have any of the following properties, alone or in combination…
8/16color-friendly colorschemes use the terminal emulator's 0-based 16 colours palette. Since various terminal emulators have different defaults and that palette is user-configurable it is impossible to predict accurately how it will look like.
You can expect these colorschemes to work reasonably well in most terminal emulators.
256color-friendly colorschemes use a semi-standardised 0-based 256 colours palette with the lower 16 indices corresponding to the aforementioned 16 colours palette. This means that colours 16 to 255 can reasonably be expected to look the same across modern terminal emulators.
You can expect these colorschemes to work well in many terminal emulators if your $TERM environment variable is set to something ending with 256color, xterm-256color being the most common correct value.
GUI-friendly colorschemes use hexadecimal values like in HTML/CSS for the best possible experience. If a colorscheme is GUI-friendly, it is automatically true-colors-friendly, which makes it suitable for use in terminal emulators that support the so-called "true color" feature.
If you use GUI Vim, then you don't have to worry about anything with these colorschemes. If you use Vim in a terminal emulator, then you will have to check if it supports the "true colors" feature and, if that's the case, enable it in Vim with :help 'termguicolors'.
Colorscheme authors are usually explicit about those things so you should be able to tell if a colorscheme fits your needs or not just by reading its README. If that is not the case, you can try looking for these hints in the code:
ctermbg and ctermfg only set to colour names or to numbers 0-15 means that the colorscheme is 8/16color-friendly.
Note that the name notation is more portable than the number notation.
ctermbg and ctermfg set to numbers 0-255 means that the colorscheme is 256color-friendly.
guibg and guifg present means that the colorscheme is GUI-friendly/true-color-friendly.

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.
which has been set up to used a slightly customized solarized theme as depicted below
I am now opening vim (which has also been set up to use its counterpart solarized colorscheme)
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)
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.
Removing line
set termguicolors
from .vimrc fixed it

Vim doesn't show colors that macvim does

I have tried two schemes, desert and wombat and I have set the colorscheme in my .vimrc file. When I open vim from my shell I don't see the color of the scheme, but when I open with MacVim I do. In both, when I type :colorscheme I see the scheme that is set in the .vimrc file, but I fail to see why I don't see the colors.
As a note, I installed the spf13 distro and uninstalled it using the script provided.
Any thoughts of how can I troubleshoot this?
First, check how many colors are supported by your terminal:
:echo $TERM
:set t_Co?
The colorscheme must actually support terminals by providing term= and cterm= definitions; many don't. See https://stackoverflow.com/a/12949536/813602 for how to work around this with the CSApprox plugin.
Inspect the colorscheme file (found in the colors/ subdirectory), or use the :highlight command to list the current color definitions.
Terminal emulators are limited to 256 colors max and often need manual setup to go beyond 8 or 16.
The coolest Vim colorschemes are designed for GVim/MacVim which can display thousands of colors.
Because of 1 and 2 it is impossible to fully emulate a GUI colorscheme in a terminal emulator if the GUI colorscheme uses colors outside the 256 colors in the X11 palette.
However, you could:
use a colorscheme that works in GUI and CLI
use a colorscheme that works only in CLI and another that works only in GUI and switch between them in your ~/.vimrc depending on the context
use a plugin that converts your GUI colorscheme on the fly: this one, this one, this one or this one
edit your colorscheme manually to add terminal support
Terminals support 88 or 256 colors. Even if your terminal supports 256 colors, you have to specify that your terminal support it in your vimrc. (cf. Using GUI color settings in a terminal)
set t_Co=256
Concerning your background, you should maybe specify that you are using a dark or a light background if your theme doesn't already declare it.
set background=dark
set background=light

gvim color scheme to match vim in xterm

I've the same question as Change GVim Color Scheme to be Like Command Line Vim
I specially like the 'darkblue' scheme on vim (through putty). Can there be some script which changes the darblue color scheme and changes the guibg and guifg to match the values in ctermbg and ctermfg.
First you must be aware, maybe you are, that most terminal emulators come with the ability to let the user define a 16 colors default palette. If 256 colors support is not activated explicitely, most - if not all - terminal emulators will default to those 16 colors.
Because each terminal emulator comes with its own default colors and those can be modified by the user there's no way to tell the value of DarkRed or even Black without actually looking at the configuration file or preferences window of your terminal emulator.
Assuming that you are not running in 256 colors mode, you should find where the default/custom colors are defined in your terminal emulator and note their hexadecimal value.
Here is my own colorscheme, in Gnome terminal:
Once you have all the values, you can make a copy of the colorscheme:
$ cp /usr/share/vim/vim7x/colors/darkblue.vim ~/.vim/colors/darkblue.vim
and change all the guibg and guifg to the values you noted earlier.
Good luck.
Vivify provides colorschemes that usually support both terminal vim and gvim. Try downloading your scheme there.
you can use this way...
:colorscheme darkblue
this is worked in the gvim and xterm.
if you want to change the command line vim you can use this method.
this is same like as the gvim.
first you can type :colorscheme then press the tab it will give more color scheme.
which you you can set.
Instead of trying to downgrade the GVIM colors to the limited set of terminal colors, I would (assuming you have a "modern" terminal emulator that supports 256 colors) use the CSApprox plugin to get a very close rendition of the GVIM colors in the console, i.e. upgrade the terminal colors.
I'm surprised this isn't up here. There's a plugin called csapprox that does exactly this. The coolest thing is that it does it with no configuration. Just set your colorscheme in your vimrc and it automatically loads the colors correctly in terminal vim. Add it to Vundle:
Bundle 'godlygeek/csapprox'
And restart Vim. The only issue I've found is that sourcing your vimrc breaks it. You'll have to restart vim every time you want to source the vimrc with :so ~/.vimrc.

command line VIM does not change background (stays black)?

I have tried this in both gVIM and VIM
the background is correctly applied in gVIM but not in VIM, it just stays black.
I use the command, :color zenburn
I am running this in Windows XP, Command Prompt
I also wonder how many colours command prompt in xp supports.
The colour sets between "gui" vim (gvim) and "console" vim (vim) are completely different. They can even be completely different for the same colour scheme.
I'm unfamiliar with the "zenburn" scheme, but it sounds like it makes different choices depending on whether you're using the GUI or not.
The :highlight command has different arguments (term=, cterm=, gui=, etc) that define the different colours used by vim in different modes. You should be able to look at your zenburn.vim colour definition file to see what it is using.
The colors for the GUI version and the console version of Vim are set differently in each colorscheme file. They don't even have to be set at all (some colorschemes define only the values for the GUI version and vice versa).
That being said, open up your colorscheme file (zenburn.vim) and look it up. If you're interested in the background color, check it up for a line looking similar to
hi Normal guibg=... guifg=.... ctermbg=.... ctermfg=...
or something similar.
The values should be there - change them to your liking if you wish.
In a windows command prompt, I find only 16 color color schemes work well. You may prefer to install cygwin and include mintty in the installation. mintty is a better terminal and I have no problem with 256 colors. http://code.google.com/p/mintty/

Resources