1

I am using Vim 7 on Ubuntu 16.04 (gnome) and the terminal emulator I am using is terminator.

I really like the aristocrat/brogrammer colorscheme for Python and so I copy-pasted it in ~/.vim/colors/brogrammer.vim.

Now here's my problem: when I run vim inside terminal and then set colorscheme to brogrammer then I get ugly black & white look, like so

ugly

on the contrary, if I press super, type vim (i.e. if I launch it as a program from dash and not by typing vim in terminal) and then set colorscheme to brogrammer I get beautiful colors, like so

nice


Why is this happening? what can I do to show those beautiful colors even when launched from terminal?

1

Upon closer inspection I found that the vim instance showing correct colors was in fact being run on gnome-terminal, as seen by ps aux | grep -i term.

Evidently, the problem can be sorted by explicitly setting t_Co to 256 in the color scheme's .vim file so as to ensure consistent behavior across all terminal emulators supporting 256+ colors.

So,

why is this happening: different terminal emulators default to different color bit ranges.

what can I do...: Two possible solutions:

  1. In your .bashrc or .zshrc or whatever, set TERM such that it ends with -256color, something like set TERM=xterm-256color (thanks to this and @Rich)

  2. Or, if you don't what to mess with terminal's settings; open the desired color scheme's .vim file and add the line set t_Co=256 near the top

  • If OP uses Vim 8+ or NeoVim 0.2+ then should use set termguicolors instead (if terminal supports that). – Hauleth Oct 9 '17 at 22:18
  • If t_Co isn't already set to 256, then that means your terminal is configured incorrectly. Overriding it in Vim is a workaround, but a better solution is to fix your terminal configuration. What's the output of tput colors when run in your terminal? – Rich Oct 10 '17 at 9:01
  • I was having the same issue on Google Cloud Shell – readyready15728 Nov 23 '18 at 0:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.