简体   繁体   中英

Vim Solarized colors wrong when SSH'ing from Mac to Ubuntu server

When using SSH from my Mac to an Ubuntu 16.04 server, the colors in Vim when trying to use the Solarized theme are incorrect. A few details about my setup:

Mac Terminal.app using xterm-256color along with the Solarized Dark profile.

Ubuntu 16.04 also using xterm-256color and ZSH (Zprezto) as my shell of choice.

Here are two screenshots of my .vimrc, the first details how it looks without the solarized colorscheme enabled and the second with solarized and its recommended settings enabled. I've tried both set t_Co=16 and let g:solarized_termcolors=16 (which is commented out in both screenshots) but it didn't help.

Solarized Disabled: 没有启用太阳能

Solarized Enabled: 启用太阳能 ]

Did you read the suggestions from the author? It is suggested that you set your terminal's color palette to a custom profile provided by the author. From the Vim page on his site :

IMPORTANT NOTE FOR TERMINAL USERS:

If you are going to use Solarized in Terminal mode (ie 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 . If you use Solarized without these colors, Solarized will need to be told to degrade its colorscheme to a set compatible with the limited 256 terminal palette (whereas by using the terminal's 16 ansi color values, you can set the correct, specific values for the Solarized palette).

If you do use the custom terminal colors, solarized.vim should work out of the box for you. If you are using a terminal emulator that supports 256 colors and don't want to use the custom Solarized terminal colors, you will need to use the degraded 256 colorscheme. To do so, simply add the following line before the colorschem solarized line:

 let g:solarized_termcolors=256 

Again, I recommend just changing your terminal colors to Solarized values either manually or via one of the many terminal schemes available for import.

So following his advice, you should import the custom color palette to your terminal application.

Based on your screenshots, I believe you are using Apple's Terminal app. You can download Solarized from the homepage , and once unzipped you should find color files for Terminal in the osx-terminal.app-colors-solarized folder. There are four versions as of this writing:

  • Light
  • Dark
  • Light (xterm256-color)
  • Dark (xterm256-color)

After a lot of back and forth, using solarized-osx-terminal-colors which is updated for more recent versions of the Mac Terminal.app solved the problem. My .vimrc just contains

syntax enable
set background=dark
colorscheme solarized

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM