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

4

13

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?

Rollick answered 30/12, 2011 at 20:7 Comment(6)
Is there a difference in light vs dark background in one of them? Also please post your ~/.vimrc for the machine in questionHowlan
@mike-pennington vimrc added. I have seen this problem in other computers too.Rollick
which gvim? Technically it could be either vim-gtk or vim-gnomeHowlan
a good strategy is to use your .gvimrc to set a colorscheme for your windowed environment, and .vimrc to set the scheme for your CLI environment.Crammer
possible duplicate of Why don't most vim color schemes look as nice as the screenshot when I use them?Palaeozoology
Used CSApprox The .vimrc instructions from here.Zelda
H
11

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.

Howlan answered 30/12, 2011 at 20:33 Comment(4)
Definitely CSApprox "Make gvim-only colorschemes work transparently in terminal vim " is a good solution.– THXRollick
Ah, that should be in the core vim package. Thanks @MikePennington!Sulfanilamide
Wow, it even improves spell checking - makes underlining work, instead of background colour change. Awesome!Sulfanilamide
@CoryKlein, 2 to the power of 8Howlan
M
9

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.

Marquise answered 30/12, 2011 at 21:56 Comment(0)
L
2

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.

Loki answered 4/8, 2014 at 14:38 Comment(0)
T
1

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.

Tricotine answered 30/12, 2011 at 20:28 Comment(2)
+1 you right about the palette issue (KDE in my case), thanks.- any way to workaround this?Rollick
Is your vim set up to use 256 colors or just the minimal 16 color scheme? Check out vim.wikia.com/wiki/256_colors_in_vimTricotine

© 2022 - 2024 — McMap. All rights reserved.