wandadars
wandadars

Reputation: 1183

Why is vim syntax highlighting on different terminals?

I am running a standard installation of OpenSuse 42.3. I ssh to the Opensuse machine via my MacOS computer. When I use vim to view files in the terminal window the syntax highlighting is pleasant to look at. I also have a Docker image of a stock installation of OpenSuse 42.3 installed on my OpenSuse machine. If I boot up the container and open a python file with vim within the container, the syntax highlighting looks different. I did a diff on the contents of the /usr/share/vim/vim74/syntax/python.vim, and there were no differences between the syntax file that is being used on the OpenSuse host and the OpenSuse container.

Below on the left is what I see when I ssh from my Mac to the OpenSuse machine and open a python file. On the right is what I see when I start the docker container ( still in the same terminal window that I started for the image on the left).

Python file when using vim to view the file on the host OpenSuse Python file when using vim to view the file on the container OpenSuse

Shouldn't the display on the terminal window of the syntax highlighted file be the same if the vim syntax files are the same?

Upvotes: 2

Views: 560

Answers (1)

Ingo Karkat
Ingo Karkat

Reputation: 172570

The highlighting in the terminal can depend on the number of available colors. Some colorschemes have separate branches of color definitions depending on how many are available. You can check for yourself via

:set t_Co?

You probably get 256 for TERM=xterm-256color and only 16 for TERM=xterm.

Though you can just force :set t_Co=256 and reload your colorscheme, it's better to fix the root cause, i.e. the wrong TERM value.

Upvotes: 3

Related Questions