I have OSX Yosemite with iTerm2. I connect via ssh to my virtual machine with Debian 8. When I run vim all colors are messed up.
iTerm2 has xterm-256colors on.
A number of things can affect your Vim colorscheme.
Make sure iTerm has the terminal type correct. As you indicated already, you use xterm-256color.
Make sure your remote shell has a matching terminal type, which you can verify with echo $TERM. If it is not set already, configure your shell with something like
# For sh, bash, zsh, ksh
export TERM=xterm-256color
# For csh, tcsh
setenv TERM xterm-256color
If the color scheme you are trying to use assumes that 256-color support is available, you may also need to add to your .vimrc:
set t_Co=256
Lastly, color schemes can be affected by the background setting in Vim, which you can set to either dark or light. To see what it's set to,
:set background?
And to set it one way or the other in your .vimrc,
set background=dark
(or light).
Related
I've been working on moving my development setup to a new Ubuntu based partition from Mac OS.
I'm currently having trouble getting the background to stay solid inside of tmux.
I have TERM set to xterm-256color in my .bashrc and vim works as intended outside of tmux. I have also aliased tmux to "tmux -2" and added
set -g default-terminal "screen-256color"
to my .tmux.conf.
My .vimrc contains:
set t_Co=256
set background=dark
color Tomorrow-Night
I suppose the best way to explain this is with images... Here is the intended look outside of tmux
(Tomorrow-Night colorscheme):
And here is what I am experiencing inside of tmux:
As you can see, the terminal background is bleeding through where there is no text.
Thanks!
I just tried reproducing your setup on my machine and I get a similar problem with the background.
It seems setting TERM to xterm-256color in your .bashrc overrides set -g default-terminal "screen-256color" from tmux and that causes issues. This makes sense as bash is running inside tmux and its setting override those from tmux.
You can easily verify this by running echo $TERM in bash within tmux. With your current setup it will be xterm-256color which is a no-go as Tmux explicitly requires this to be set to screen-256color.
A quickfix to verify this theory is just removing or commenting out a line in your .bashrc where you set TERM and trying things out.
A proper solution would be to have something like this .bashrc:
[ -z "$TMUX" ] && export TERM="xterm-256color"
The above line will:
set TERM to xterm-256color if bash is running standalone (no tmux)
will not override TERM if running inside tmux
I'm struggling to make the Solarized colorscheme correctly working on an Ubuntu 13.10 machine inside Vim inside tmux inside the gnome-terminal.
I've started configuring gnome-terminal using the script on this repository and it displays the colors correctly. The same goes if I run Vim (with the official Solarized colorscheme) inside the terminal, without tmux.
Then I tried to configure tmux using this. It happens that when I run Vim the syntax highlight for php or javascript code is wrong or, at least, different from the one I see running Vim without tmux. I've tried also running tmux as tmux -2. The colors are different, but still the syntax highlight is not correct.
I tested it out and got it working in the following way:
Install gnome solarized colorscheme. You can get it from https://github.com/aruhier/gnome-terminal-colors-solarized.
Install solarized colorscheme for vim. You can get it from https://github.com/altercation/vim-colors-solarized. In .vimrc you should add following settings:
set t_Co=256
set background=dark
colorscheme solarized
Set correct TERM variable by adding following line to your .bashrc/.zshrc
export TERM=screen-256color-bce
Run gnome-terminal, tmux, vim and profit.
These days GNOME Terminal comes with Solarized colours built in. To use it, you need to change two settings in the profile that you're using. The obvious one is the text and background colour. You also need to set the palette to Solarized, though. You can find this setting below the one for the text and background colour. At this point, setting t_Co or g:solarized_termcolors in Vim shouldn't be necessary.
The palette is the part that I missed at first, which caused me to puzzle why the text in Vim and other applications was bright blue.
With Steven Harman's Solarized tweak for Console2 I can more or less use the Solarized color scheme in win32 vim. But once in a while I find myself in vim via a vanilla cmd.exe window and the Solarized 16-color colorscheme is not aligned to it gui equivalent.
So I'd like to fix this inside my vimrc, but how can I check if console vim is being used in Console2?
Thanks!
In Console2, you can set arbitrary environment variables by modifying the shell invocation (from the Settings dialog, or directly in the XML config). For the default Windows command prompt, use a value of:
cmd.exe /K set EMULATOR=console2
For Cygwin Bash, something like this should work:
C:\cygwin\bin\bash.exe -c "export EMULATOR=console2; exec /bin/bash -i"
Then, check for the $EMULATOR value in a conditional in your .vimrc, as outlined by romainl's answer.
See if your terminal emulator sets an environment variable or if you can set one in one way or another.
In bash, one would do:
$ export EMULATOR=console2
With that out of the way, you can put something like this in your _vimrc:
if $EMULATOR == "console2"
colorscheme foo
else
colorscheme bar
endif
I really apologize because I know that this question has been asked multiple times. I have gone through all of the previous questions, but I still have yet to have any luck setting up the Solarized colorscheme in my Terminal.app for OS X Mountain Lion. So far this is what I have:
My .vimrc currently is set up like the following:
set number
syntax enable
set background="dark"
colorscheme solarized
but for my MacVim I get this:
This is what I would like to have my Terminal.app display as well. The only thing that my .vimrc says for MacVim is
colorscheme solarized
Edit
After I had asked this question, I eventually moved to iTerm2, which proved to be much nicer.
I'm not 100% sure, but I think the newer versions of OS X terminal will support 256 colors out of the box.
I had the same issue, then I downloaded an alternate implementation of the Solarized theme for the Mountain Lion terminal, and this appears to have solved it.
Just add let g:solarized_termcolors=256 to your vimrc
Ensure that TERM is set to xterm-256color to let Vim know that the terminal supports 256 colors. This is the default for Terminal in Lion 10.7 and later†, so your preferences were customized at some point.
To tell Terminal to set TERM to a different value, go to
Terminal > Preferences > Settings > [profile] > Advanced
and change Declare terminal as: to xterm-256color.
[Note that all this preference does is set the value of the TERM environment variable. It does not alter the behavior of Terminal or affect what sort of terminal it emulates.]
† Prior to Lion, the default was xterm-color.
Add to your ~/.vimrc
" Solarized Dark
syntax enable
set t_Co=256
let g:solarized_termcolors=256
set background=dark
colorscheme solarized
This works on both ansi and xterm-256color versions of Solarized. Tested on Terminal 2.3 on a new OS X 10.8.5 VM installation.
NB This answer supersedes the previous one that proposed changes to the profile swatches. I recently realised I had these commands in my .vimrc file that actually configured Solarized.
To run vim with 256 colors you must use a 256 color terminal. You can set your terminal to xterm-256color, for example, with export TERM=xterm-256color and then start vim. You can export this $TERM setting in one of your terminal startup scripts (e.g. .bashrc, .zshrc, etc.).
It may seem counterintuitive, but use set g:solarized_termcolors=16. This is confirmed to be the correct setting with :h solarized.
I want to use solarized, which gives a decent color scheme in Vim. It works by setting the 16 colors ansi colors in the gnome-terminal. It works fine if I use Vim from bash, but in zsh the colors are off. Some letters have the right background, but most have too light background. What is it about zsh that interferes with the ansi colors as displayed by Vim?
I can't reproduce this - if this is still an issue, perhaps giving relevant sections of ~/.bashrc, ~/.zshrc, ~/.vimrc etc might help.
I'm using the Solarized vim colorscheme, and the linked Gnome-Terminal settings in the following screenshots. As you can see, they appear to be identical - there's certainly no color issues in either zsh or vim that I've noticed (I don't use bash much).
My zsh settings are taken from oh-my-zsh, and my prompt is a hacked-up version of Phil!'s ZSH prompt (I have messed with the coloring of Phil!'s ZSH prompt, because it didn't play well with the Solarized iTerm2 colors). However, I do not think I've messed with anything that would affect the Solarized colorings between bash and zsh in vim. Certainly the vim settings are identical between the two screenshots below.
I had the same problem on Ubuntu 14 with zsh.
This fixed it (in the .vimrc)
let g:solarized_termcolors=256
set background=light
colorscheme solarized
I know this is a veeery old question but I had the same problem and came across this so I thought it could still be useful to someone if I answered it.
For me TERM was not set to xterm-256color in zsh like it was in bash so the colours were messed up in vim.
Simply adding export TERM=xterm-256color to the .zshrc file fixed the problem.