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

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/

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

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.

Why vim color schemes differs between gvim and a normal terminal?

Why vim color schemes differs between gvim and a normal terminal?
For example many schemes of this showcase don work in a normal terminal.
I am saving all new schemes to ~/.vim/colors/ and set with :colorscheme cool
Any way to solve this?
Terminal windows (such as xterm) are typically limited to 2**8 colors. On the other hand, a GUI term can have as many colors as your graphical windows desktop.
Many vim color schemes are designed for either the GUI or the terminal; if they are designed for a GUI, it's unlikely they would display in a terminal well by-default.
If you need to convert a GUI scheme to terminal (256 colors), you can use the CSApprox plugin.
The two current answers are pretty good. Your vote should go to Mike's because there is no perfect workaround.
Vim colorschemes usually specify colors separately for the GUI and for the CLI. Some colorshemes don't define anything for the CLI and those that do use the X11 colors.
These X11 colors (noted 0-255) have been more or less standardized since a very long time and only really work in terminal emulators that support 256 colors. In other less capable terminal emulators the higher numbers are skipped and your colors are messed.
GUI Vim can also use these 256 colors plus any color you might want, as long as it's specified with an hexadecimal notation (#00d6e3).
Because GUI colorschemes can use thousands of colours, and CLI colorschemes can only use 256 colors the values used for the CLI can only be approximations of those used by the GUI. That's why CLI Vim can't really look like GUI Vim, even if you use a modern terminal emulator.
If your colorscheme of choice insists on using colors outside of the X11 range you will never have CLI Vim and GUI Vim look the same.
The only way to sync the colors of GUI and CLI Vim I see is to dumb down the GUI colorscheme by using X11 colors only.
Theres a new kid on the block called CSExact which moldes you terminal to the exact colors of the colorscheme. Colors look a lot better than with CSApprox.
This plugin allows the use of GUI (GVim) color schemes in (some) terminals.
This is done by using terminal magic to modify the terminal's color palette
on startup and each time a color scheme is loaded.
Because gvim directly selects X11 colors, while the terminal vim uses the available terminal palette.
So if you use a modern terminal (gnome, kde or even OS X) you can change the palette of available colors and VIM will look completely different. GVIM, on the other hand, sets the colors directly without the intermediate translation layer of the terminal app.

How to make color settings look the same in vim as in gvim

When I put the following in .vimrc
colorscheme blue
It gives me a nice blue colorscheme in gvim. However, when I use vim, it is light blue instead. Is there a setting I can change so that gvim and vim look the same? If not, then is there a way I can set it up so that my gvim settings do not interfere with my vim settings?
As well as John's suggestion of using .gvimrc, there are a couple of other interesting alternatives:
If your command-line vim is compiled with +gui (:echo has("gui"))* and you have a 256 colour capable terminal, you can use the CSApprox plugin to convert the GUI colour scheme into a matching command line one.
If your command-line vim doesn't have +gui, you could try (I haven't used this one) the guicolorscheme plugin. The guicolorscheme plugin parses the colour scheme file, so it isn't as robust as the CSApprox one (it almost certainly won't work with my colour scheme for example.
There's a lot more information on both of those methods here and here.
* Regarding has("gui"):
If you're not interested in +gui, stop reading now!
Personally, I'd recommend this as it simplifies things a bit - you get the opportunity to type :gui if you want to change from terminal to GUI and as you inevitably have +X11 and +xterm_clipboard as well, you can copy to the X clipboards from console vim. If your vim doesn't have +gui, the easiest way to fix it is to create a link in your personal bin directory to the GUI executable:
ln `which gvim` ~/bin/vim
GVim will quite happily work as a console vim if the executable name is vim. A "default" build from the vim source with GUI enabled will create one executable (vim) and lots of links to that executable like gvim, gview, view, vimdiff etc. Most Linux distributions seem to compile them separately though, in order to minimise requirements of the basic Vim (so you can use vim without installing X). As such, I tend to recompile and install in /usr/local with the features I want as I always have X installed (it doesn't have to be running, just installed).
set your vim settings in the .vimrc file, and set the gvim settings in the .gvimrc settings file.
Just pick a different colorscheme in the .gvimrc...
If you are using a modern terminal which support 88 or 256 colors(most of them do like gnome-terminal or roxterm(on linux) not sure about Mac or Windows) , you should check out this vim script CSApprox(http://www.vim.org/scripts/script.php?script_id=2390). This scripts make the color schemes made for gvim, work with terminal vim.

Resources