7

Many terminal emulators allow you to define colors:

enter image description here

Rather than trying to approximate (and duplicate!) the same theme in a Vim colorscheme, is there a way to tell terminal Vim to output ANSI escape codes for the colors I've already defined ("red", "green", "yellow", "magenta", etc)?

If not, why not?

7

Assuming your terminal emulator doesn't claim to support 256 colors ($ echo $TERM should output a string that doesn't contain 256color) and you didn't lie to Vim about that (:echo &t_Co should output 8 or 16), Vim should honor the "ANSI" colors you defined in your terminal emulator.

The built-in colorschemes all use those "ANSI" colors — either by name or by number — by default but many third party colorschemes are specifically designed for the GUI and/or for 256 colors terminal emulators. Those colorschemes generally don't work at all (or very poorly) in 8/16 colors setups.

So you will need to experiment with built-in and third party colorschemes to find the "perfect" combination.

You can look for the clues below to tell if a colorscheme will work in your setup:

ctermfg=red    use of names means it works in 8/16 color terminals
ctermfg=7      use of numbers below 16 means it works in 8/16 color terminals
ctermfg=123    use of numbers between 16 and 255 means it works in 256 color terminals
guifg=...      means it works in GUI Vim

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.