After going down the wrong rabbit hole, looking at themes for terminal in Ubuntu20.04 I realized what I really needed to change was the colorscheme in vim. I have found they are listed in /usr/share/vim/vim81/colors/*.vim

One of the things I don't understand, is that Putty seems to have the colors I like, am used to, and can most easily see, when when I type ":colorscheme" while a file is open in the vim editor, it outputs "default". I DO NOT understand why the default theme looks correct to me in PuTTy, but not in Terminal. If I had the option of changing the font family and size in PuTTy in Ubuntu20.04 I would likely just use it. As it is, it is too small, I can barely see the font. Thus, I need to use terminal. However, the colors make it hard for me to see.

The colors I want (specifically for Python, but putty just always has the right colors) are the ones that PuTTy seems to be using when I type ":colorscheme default" but I want these colors for terminal.

Does anyone know how to get "terminal" to display the same colors that PuTTy displays? Or has anyone created a custom "*.vim" color file that I can download and use as the colorscheme in VIM for my terminal?

Terminal, using ViM81's :colorscheme=default:

Terminal, using ViM81's :colorscheme=default

VIM, using ViM81's :colorscheme=default:

VIM, using ViM81's :colorscheme=default

If any one can provide a link to a page that tells me what to do, or to a colorscheme.vim file for terminal's VIM, I'd really appreciate it.


Solution 1:

A colorscheme is essentially a sequence of Ex commands like this one:

highlight Foo cterm=NONE ctermbg=red ctermfg=224 gui=NONE guibg=#ff0000 guifg=#ffdfdf

that define, for a given highlight group (for Foo, here):

  • a text style for terminal emulators with cterm,
  • a background color for terminal emulators with ctermbg,
  • a foreground color for terminal emulators with ctermfg,
  • a text style for GUI Vim with gui,
  • a background color for GUI Vim with guibg,
  • a foreground color for GUI Vim with guifg.

Since you are talking colors and terminal emulators, only ctermbg and ctermfg are relevant.

ctermbg and ctermfg can be given different kinds of values whose effect might differ depending on your environment:

  • 1-15 would mean "use color at given index in the so-called ANSI palette",
  • red would mean "use color with given name in the so-called ANSI palette",
  • 16-255 would mean "use color at given index 224 in the so-called xterm palette".

There are literally thousands of custom colorschemes in existence and colorscheme authors may favor one notation over the other, mix them, or even don't use them at all because they only care about GVim. "YMMV" is not a joke when talking about Vim colorschemes.

What notation is used by the default colorscheme mostly depends on your environment, which has thus a lot of influence on how things look.

For example, if your $TERM is something like xterm, Vim assumes that your terminal emulator can only display 8-16 colors so it uses the first notation. This means that the colors you see are all taken from your terminal emulators so-called ANSI palette, which a) changes from terminal emulator to terminal emulator, and b) can generally be modified by the user anyway. In this context, there is no way whatsoever for Vim to make any guarantee about what colors will be used in the end.

If your $TERM is something like xterm-256color, Vim assumes that your terminal emulator can display 256 colors so it uses, and that's really annoying, a mix of the first and third notations. Colors 16-255's big advantages over colors 0-15 are a) that they are not easily changed by the user, and b) that they can reasonably be expected to be the same on most terminal emulators that implement them. The annoying bit is that Vim uses lots of colors in the 0-15 range, which can't be trusted, in combination with colors in the 16-255 range, which can be trusted.

The ultimate consequence is that default can't be expected to be consistant across terminal emulators without some fiddling.

Where to go from there?

First, if you expect n Vims, in n terminal emulators, on n platforms to behave the same, the very least you have to do is:

  • make sure $TERM matches,
  • make sure it actually is the exact same Vim version with the exact same patches applied,
  • make sure colors 0-15 of all terminal emulators are the exact same,
  • and, since you mentioned font size, make sure you have the exact same font installed everywhere and all your terminal emulators set to use it at the exact same size.

If you want to stick with default, then checking all of the above should get you closer to where you want to be. If you can't, then you can give up right away.

Second, Vim comes with lots of alternative colorschemes out of the box, so you could try them and see if there is one that works better for you:

:colorscheme <Tab>

Third, as mentioned above, you could try some of the many custom colorschemes publicly available. Be aware that they may come with different sets of features and different requirements.