Vim colors not working properly in terminal
Solution 1
To complete Akira's advice, vim in term mode uses the terminal color palette. From the vim solarized colorscheme repo :
If you are going to use Solarized in Terminal mode (i.e. not in a GUI version like gvim or macvim), please please please consider setting your terminal emulator's colorscheme to used the Solarized palette. I've included palettes for some popular terminal emulator as well as Xdefaults in the official Solarized download available from Solarized homepage.
For gnome-term, there are instructions to set up the color palette.
Solution 2
vim
use the power of your "terminal" to draw the characters onto the screen. thus, how the drawn chars look depend largely on what the "terminal" is capable of. the "terminal" uses an enviroment variable to tell the apps running inside it about its capabilities: TERM
.
if you want to use vim
to use 256 colors you need 2 things:
- a terminal capable of rendering at least 256 colors
- the right
TERM
variable (xterm-256color
)
so, try this:
$ export TERM=xterm-256color
$ vim
also read up more upon the topic on http://vim.wikia.com/wiki/256_colors_in_vim
Related videos on Youtube
yasith
Updated on September 18, 2022Comments
-
yasith over 1 year
I'm using gnome terminal, and vim with solarized color theme. When I open vim in the terminal, it's illegible.
But when I open a file in gvim, the color scheme works perfectly.
Gnome terminal's color scheme is also solarized. One thing to note is that, if I set an illegal value for background, I get the expected background color (but also an error).
-
Admin over 12 yearsCould you add your .vimrc and .gvimrc?
-
Admin over 12 years.vimrc is here there's no .gvimrc. I already checked the question on the 1st comment. My &term and $TERM are both the same (xterm-256color).
-
Admin over 12 yearsFound a temporary fix, adding this before colorscheme solarized. Changes the colors to the solarized theme. But, the line numbers column keeps having a brownish-grey color.
-
Admin over 8 yearsMight I suggest installing
terminator
(a great, solid terminal emulator), and then goingPreferences>Profiles>Colors>Palette
and selectingSolarized
. Additionally, (as I have it) you can go toKeybindings
and mapsuper+p
or whatever you want to change to the next profile (which would contain a different profile). I have two profiles - solarized and another more colorful one that I do everything butvim
in. Whenever I go intovim
now, I simply hitsuper+p
and then my palette matches that which the creator of solarized had intended. Cheers
-
-
yasith over 11 yearsHad the same problem today, when trying to setup a new system, and after setting the colors in ~/.Xresources and merging using xrdb. The color problems with vim in terminal session is gone.
-
artfulrobot about 11 yearsUseful gconf code block to set up gnome-terminal: xorcode.com/2011/04/11/solarized-vim-eclipse-ubuntu
-
Yamaneko about 11 yearsBy running this commmand, I was able to use the
vim
extensionPowerline
in mygnome-terminal
. Thank you! -
Ahmed Fasih over 7 yearsSee akira’s answer below for the magic incantation:
export TERM=xterm-256color vim
(and then put theexport
command in your shell startup file, like bashrc). -
Emile 81 over 7 yearseven with 256 colors, a lot of colorschemes look off.. but I guess that is explained by the color palette