I'm running vim in the default Mac terminal and I'm trying to change the color scheme to one of the included color schemes, but none of them seem to be displaying properly.
For example, if I type :colorscheme blue, the colors change but there is a white border around the background.
Additionally, if I type :colorscheme desert, which is the color scheme I want to use, the syntax highlighting changes, but the background color does not.
Note that the desert color scheme is ostensibly supposed to look like this:
Why are these color schemes not displaying properly, and is there a way to fix them? Thanks!
vim's set background={light|dark} is not designed to change your background color, it is designed to work with your existing background color and give you colors that show up on that background.
Some colorschemes have multiple options to try and reproduce what the designers wanted in a variety of settings. For example, the colorscheme I am using has a base section with all the color settings followed by a 256 color specific section:
....
hi LineNr guifg=#465457 guibg=#232526
if &t_Co > 255
hi Normal ctermfg=252 " ctermbg=232
hi CursorLine ctermbg=234 cterm=none
...
which sets all the colors based on having a 256 color terminal, so that way people with 256 color terminals can still get close to what the colorscheme author intended, since a 256 color terminal cannot draw RRGGBB colors.
Likewise, colorschemes can respect background and change the colors they are using to be visible on that background color (so dark terminals don't have comments as dark blue, for example).
Lastly, vim only attempts to draw the background where it can draw characters, i.e., only the printable area of the screen. If your terminal width is, for instance, between 64 and 65 COLUMNS wide, then vim can only draw 64 characters, and there will be some space around the edges where vim doesn't try to draw, leaving the terminal's default background.
On Mac's Terminal.app, the easiest way to change your background color is to go to Preferences -> Profiles and either choose a default theme or edit the Background "Colors & Effects" section to be what you want.
Related
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.
I'm using coc.nvim plugin for C++ in my vim editor, here it's showing error but its colors hurt my eyes, I've been searching for solution but still don't know how to customize the colors
cocnvim floating window color
To choose another background color you can use
:highlight CocFloating ctermbg=color
And to change the foreground (text) color of the error message use
:highlight CocErrorFloat ctermfg=color
where color is either a color name or a color number (generally from 0 to 15).
To read more on color values
:h cterm-colors
GUI
If you want to use a GUI for vim, you should consider using guibg and guifg arguments in addition to ctermbg and ctermfg.
guifg and guibg value is either a color name or a hex-encoded RGB value (ex. #ff0000 for red).
GUI color values can be found here
:h gui-colors
In their github Discussion, there is a conversation that can solve all problems with Coc FloatingWindow:
here is the link:
enter link description here
I am using vim with the default color scheme on dark background, but in many cases, the white font is highlighted with light pink color, making it hard to read. How do I fix this (change highlight color) in the default color scheme?
Here is an example of the problem:
You can override the colors displayed with the :highlight command, which can be called from your vimrc. The documentation is really quite good for this, and can be read here: http://vimdoc.sourceforge.net/htmldoc/syntax.html#:highlight.
I have the following in my .vimrc:
hi CursorLine ctermfg=00 ctermbg=00 cterm=bold
I should be unable to read the line the cursor is on, but I am able, because the text appears in grey. If I remove cterm=bold, I get true black, so it seems to be black or bold, but not both. Is "bold" a variable for a color in the theme (solarized light)? Or is my terminal theme overriding the fg color somehow? I get the exact same results in various terminal apps (on Xubuntu).
By typing :help attr-list you will get a whole list of possible values for cterm argument:
bold underline undercurl
inverse italic standout
term={attr-list} attr-list highlight-term E418
attr-list is a comma separated list (without spaces) of the
following items (in any order):
bold
underline
undercurl not always available
reverse
inverse same as reverse
italic
standout
NONE no attributes used (used to reset it)
These terms are not colors but they are considered as typographical emphasis. They add more font and shape to the text.
First, highlighting of the cursorline is disabled by default so there's no reason whatsoever to hack your colorscheme if you don't want it: just don't enable it. For the record, that feature is enabled with :set cursorline and disabled with :set nocursorline.
See :help 'cusorline'.
Second, the "bold" keyword is passed more or less directly to your terminal emulator which is ultimately in charge of deciding what to do with it. It may display "bold" text with a bolded font or use a brighter or color or… whatever. Use "bold" only if you know how your terminal emulator will react to it.
Third, Solarized is an over-engineered and very poorly written colorscheme that's a lot harder to hack than necessary. It's really a bad platform for experiments and customization.
I have just started using Vim in a terminal (PuTTY or MinTTY), after always using gVim. However, when using syntax highlighting, rather than the actual text colour changing appropriately, its background is changed to whatever colour -- and it looks horrible!
I've set my terminal to use 256 colours and downloaded a 256 colour colour scheme. I checked that the ctermfg and ctermbg settings are as I expect, but I still get this problem... Is this a Vim or a terminal configuration issue?
Many color schemes have features that are only supported in gvim/macvim. Some color schemes such as solarized, can be configured to support 256 color terminals using a setting such as let g:solarized_termcolors=256. For other color schemes, look at plugins like this one: http://www.vim.org/scripts/script.php?script_id=1809 and this one: http://www.vim.org/scripts/script.php?script_id=2390