I have a lovely Vim colorscheme (xoria256) and it looks brilliant in GVim, but when I use normal vim
in Terminal, the colorscheme is only partially supported -- for example, the default semi-transparent aubergine background color is used. How do I make Terminal faithfully render my Vim colorscheme?
GNOME Terminal supports 256 colors, but doesn't advertise its support. You can override vim's autodetection by putting the following:
in your ~/.vimrc.
Note: if you use GNU screen, it will happily eat those 256-color codes and convert them to basic 16 colors. A better fix is to change TERM to xterm-256color before launching screen/vim.
Update for 2017: if you have a sufficiently recent Vim (7.4.1799 or newer), and a sufficiently advanced terminal emulator (xterm, or gnome-terminal based on a sufficiently recent version of VTE), you can
:set termguicolors
and terminal vim will use full 24-bit colors as defined by your vim theme usinghighlight guifg=#rrggbb guibg=#rrggbb
.A more general solution is to install the term type "xterm-256color". In 10.04 I think it's installed by default. Previously you needed to install "ncurses-term" to get it.
Then set the term type in .bashrc with something like the following:
If you'd prefer to only have the 256 colour capability for certain programs (perhaps it confuses some others) use instead:
and perhaps set that as an alias for the program.
Then check your terminal colour capabilities with:
You still may need the vim setting above to have vim recognise it. Most applications will recognise the 256 colours automatically (if they can use them).
Emacs also has colour themes that are much better with 256 colours. To check if it 256-colour capable run:
256colors.pl is Perl script that will display all the colours in your terminal.
Just include the line below into your
$HOME/.bashrc
(preferably in the last line of the file):And save it. After, restart your gnome-terminal. This change will be available not only in vim, but for all your terminal applications.
To check if it works, run this little script:
Thereafter, you will see something like the following (depends on your gnome-terminal theme):
Well, you can always configure Gvim to make it look like Vim. You just have to create a ~/.gvimrc file and paste in it these customisation tricks:
I don't think this solves your problem, but who knows ;-)
I made a separate profile for Vim which uses a solid, opaque color in the background. I just manually switch to it whenever I use Vim. Not sure whether or not there's a better method. I'd like to think so.