The background color of the currently-selected-suggestion does not contrast enough with the text to be readable. How can this be fixed?
Setting Pmenu and/or PmenuSel in does NOT improve the situation, as neither change this background color.
.exrc is EMPTY (so no color changes by me)
Using default terminal program, without changing any colors.
Using vim (8.2) on MacOS Monterey (12.5) with the M1 (arm64) cpu.
Same issue on iTerm2 using custom color scheme, so it's not the terminal's fault, I don't think.
Same problem on my side, after trial and error using
hi CocMenuSel ctermbg=darkgrey ctermfg=yellow
hi CocSearch ctermfg=blue
in ~/.vimrc
produces a reasonable contrast on my side with on a Mac with white terminal bg.
Use :hi to scroll thru the color suggestions of vim to see the possible names and color appearance.
After going down the wrong rabbit hole, looking at themes for terminal in Ubuntu20.04 I realized what I really needed to change was the colorscheme in vim. I have found they are listed in /usr/share/vim/vim81/colors/*.vim
One of the things I don't understand, is that Putty seems to have the colors I like, am used to, and can most easily see, when when I type ":colorscheme" while a file is open in the vim editor, it outputs "default". I DO NOT understand why the default theme looks correct to me in PuTTy, but not in Terminal. If I had the option of changing the font family and size in PuTTy in Ubuntu20.04 I would likely just use it. As it is, it is too small, I can barely see the font. Thus, I need to use terminal. However, the colors make it hard for me to see.
The colors I want (specifically for Python, but putty just always has the right colors) are the ones that PuTTy seems to be using when I type ":colorscheme default" but I want these colors for terminal.
Does anyone know how to get "terminal" to display the same colors that PuTTy displays? Or has anyone created a custom "*.vim" color file that I can download and use as the colorscheme in VIM for my terminal?
Terminal, using ViM81's :colorscheme=default:
VIM, using ViM81's :colorscheme=default:
If any one can provide a link to a page that tells me what to do, or to a colorscheme.vim file for terminal's VIM, I'd really appreciate it.
A colorscheme is essentially a sequence of Ex commands like this one:
highlight Foo cterm=NONE ctermbg=red ctermfg=224 gui=NONE guibg=#ff0000 guifg=#ffdfdf
that define, for a given highlight group (for Foo, here):
a text style for terminal emulators with cterm,
a background color for terminal emulators with ctermbg,
a foreground color for terminal emulators with ctermfg,
a text style for GUI Vim with gui,
a background color for GUI Vim with guibg,
a foreground color for GUI Vim with guifg.
Since you are talking colors and terminal emulators, only ctermbg and ctermfg are relevant.
ctermbg and ctermfg can be given different kinds of values whose effect might differ depending on your environment:
1-15 would mean "use color at given index in the so-called ANSI palette",
red would mean "use color with given name in the so-called ANSI palette",
16-255 would mean "use color at given index 224 in the so-called xterm palette".
There are literally thousands of custom colorschemes in existence and colorscheme authors may favor one notation over the other, mix them, or even don't use them at all because they only care about GVim. "YMMV" is not a joke when talking about Vim colorschemes.
What notation is used by the default colorscheme mostly depends on your environment, which has thus a lot of influence on how things look.
For example, if your $TERM is something like xterm, Vim assumes that your terminal emulator can only display 8-16 colors so it uses the first notation. This means that the colors you see are all taken from your terminal emulators so-called ANSI palette, which a) changes from terminal emulator to terminal emulator, and b) can generally be modified by the user anyway. In this context, there is no way whatsoever for Vim to make any guarantee about what colors will be used in the end.
If your $TERM is something like xterm-256color, Vim assumes that your terminal emulator can display 256 colors so it uses, and that's really annoying, a mix of the first and third notations. Colors 16-255's big advantages over colors 0-15 are a) that they are not easily changed by the user, and b) that they can reasonably be expected to be the same on most terminal emulators that implement them. The annoying bit is that Vim uses lots of colors in the 0-15 range, which can't be trusted, in combination with colors in the 16-255 range, which can be trusted.
The ultimate consequence is that default can't be expected to be consistant across terminal emulators without some fiddling.
Where to go from there?
First, if you expect n Vims, in n terminal emulators, on n platforms to behave the same, the very least you have to do is:
make sure $TERM matches,
make sure it actually is the exact same Vim version with the exact same patches applied,
make sure colors 0-15 of all terminal emulators are the exact same,
and, since you mentioned font size, make sure you have the exact same font installed everywhere and all your terminal emulators set to use it at the exact same size.
If you want to stick with default, then checking all of the above should get you closer to where you want to be. If you can't, then you can give up right away.
Second, Vim comes with lots of alternative colorschemes out of the box, so you could try them and see if there is one that works better for you:
:colorscheme <Tab>
Third, as mentioned above, you could try some of the many custom colorschemes publicly available. Be aware that they may come with different sets of features and different requirements.
The default colors for Vim are specified in terms of the 16-color ANSI palette. This palette goes back to EGA, and it roughly defines eight colors, possibly with a bold (bright) version of each. The difference that you're seeing is that the definition is approximate. For example, color 1 is red and color 4 is blue, but nobody mandates what color that red and blue are. Specifically, in many cases, the regular (non-bright) yellow is brown.
If you want to set the colors to be different in Ubuntu, you should be able to configure the terminal emulator in its settings. GNOME terminal, which is what it looks like you're using, should allow this. The Wikipedia page on ANSI terminal codes contains information on which actual colors are mapped to different color numbers.
Thanks to romainl I got it all working the way I wanted it to.
In VIM, when I typed in ":colorscheme" it output "default",... YET when I typed ":colorscheme default" it actually changed the colors to ALMOST match what was in PuTTy. Then, I just had to add a few adjustments to my ~/.vimrc and ~/.vim/syntax/python.vim files. Below are those adjustments...
In my .vimrc file, I had to move:
syntax on
filetype detect
filetype plugin on
From the bottom of my .vimrc file, to almost the very the top, as it was getting overwritten by something. Then, I added one line above that (:colorscheme default (to force it to switch to the "real" default")), and 5 lines below it. Now my .vimrc contains (amongst MANY other customizations):
colorscheme default
syntax on
filetype detect
filetype plugin on
hi Comment ctermbg=black ctermfg=green cterm=None
hi String ctermbg=black ctermfg=1 cterm=None
hi Statement ctermbg=black ctermfg=yellow cterm=None
hi StatusLine ctermbg=0 ctermfg=7
hi StatusLineNC ctermbg=252 ctermfg=238 guibg=#d0d0d0 guifg=#444444
Additionally, my python syntax file (located at ~/.vim/syntax/python.vim) needed these adjustments:
hi Statement ctermbg=black ctermfg=yellow cterm=bold
hi pythonStatement ctermbg=black ctermfg=yellow cterm=None
hi Conditional ctermbg=black ctermfg=yellow cterm=None
hi pythonComment ctermbg=black ctermfg=green cterm=None
hi pythonString ctermfg=1 cterm=None
hi pythonQuotes ctermfg=blue cterm=bold
Again, special thanks to the answer above from: romainl with his/her help, and the above customizations, I was able to get my VIM colors in Ubuntu20.04 Terminal to match my VIM colors in PuTTy that I was used to.
P.S. My term-type is xterm
I'm not sure if this is exactly what you are looking for, but... I ran into a problem that the color schemes in my terminal did not look like they looked on the previews on https://vimcolorschemes.com.
Adding the following lines solved to ~/.vimrc solved problem for me:
if !has('gui_running')
set t_Co=256
endif
set termguicolors
I want to replace xfce4-terminal to urxvt but there is flickering of lines with bg property set (tabline, statusline) when switching tabs in vim (or neovim). I have no issue using xfce4-terminal which I have chosen for that reason (I used xterm before). But urxvt works faster and I do really like low-latency apps. I have found that under tmux I have no flickering but when I disable its status line everything comes back. I do not use tmux and I have just installed it cause some guy mentioned it. I do not mind to use tmux or gnu screen (have no effect under it) if it is invisible (not with statusline or whatever else).
man urxvt says I am using 9.22 version.
I am glad I have found this issue. In order to get rid of annoying flickering define ctermbg property for Normal syntax group in your color scheme, like this:
hi Normal ctermfg=12 ctermbg=8 cterm=NONE
Color #8 should match with your terminal background color. I use solarized theme, so I have
*background: #002b36
*color8: #002b36
in my ~/.Xresources.
I started to configure vim so I installed pathogen and solarized.
Here is my .vimrc and the screenshot of the solarized theme at the same time.
I don't understand why I have keywords like 'set' highlighted in black?
Is it because of terminator?
It's the same problem when I open a python script, all the keywords are highlighted...
Thanks
EDIT
The real problem is that you can set different background/colors in vim, in zsh and also in terminator config. Is there a way to make it all looks like solarized? I think the problem comes from backgrounds that overlap each others. The black color is actually the background of terminator.
Colorscheme authors can build their own palette from a 16,777,216 colors palette for GUI colorschemes, the 256 colors xterm palette for 256-colors terminal emulators and the 16, user-configurable, named ANSI colors in other cases.
The obvious consequence is that it is extremely difficult to come up with a colorscheme that is guaranteed to look the same everywhere.
The choice I've made with my colorscheme was to only use colors from the xterm palette in the GUI version, making it virtually impossible to distinguish between terminal Vim and graphical Vim based on the colors alone. I honestly don't know how many colorschemes do that but the intrinsic limitations of that palette (no browns, for example) admittedly make that a bit complicated and restrictive.
For 8/16 colors terminals, I provide the values of 18 from my palette so that the user can customize his 16 ANSI colors and enjoy almost the same experience as with more capable terminals or GVim. This is something that every colorscheme author has to do and there's no workaround.
Some colorscheme authors start their work with a limited and arbitrary palette, often 16-20 colors, that they retrofit into their colorschemes. Since their palette is most of the time outside of the xterm palette, they are able to give you a pretty impressive out-of-the-box GUI experience but the 256-colors terminal experience is usually so-so, forcing you to retrograde your terminal to a xterm $TERM to enjoy the customized ANSI colors.
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.