what is the difference between cterm color and gui color? - vim

I am customizing my own color scheme for Vim but I don't know when should I configure ctermfg/ctermbg variable and guifg/guibg variable because I didn't see any differences between them at all. Is there any difference between them?
Can any one give me an illustrative example of how to use them ?
Thanks

I didn't see any differences between them at all
ctermxx is used by console version of Vim (when set notermguicolors). guixx is used in GVim, or in console if set termguicolors, and the console is capable of TrueColor, obviously. Hence you must test it in different programs to see the difference.
Also, some colors could be the same or very close to each other, e.g. "blue" is "blue" both in GUI and console.
Can any one give me an illustrative example of how to use them?
hi Normal guifg=#1034a6 guibg=#f5f5dc ctermfg=19 ctermbg=230
Should look very similar but still a little different in GUI and console
For symbolic colors names see :h cterm-colors and $VIMRUNTIME/rgb.txt. The cheat sheet of 256 color indexes for console is available here.

The separate pairs allow you to specify different colors for a terminal (which may limit you to a fixed-sized palette of colors, usually 16 or 256) and a GUI (which typically provides a much larger palette or even direct access to any color your display can handle).
For example, if you start a session in your terminal using vi some_file.txt, then ctermfg and ctermbg would be used. If you start an instance of gvim (which opens its own window independent of your terminal emulator), then guifg and guibg are used instead.

Related

Remove terminal border colors from vim colorschemes

I want the color scheme to span completely across the terminal boundaries. I am using Color Scheme Scroller Plugin to switch between different theme. I have uploaded a .gif file so that you can clearly see what I want to get fixed. Vim colorschemes doesn't completely change the color of editor. There are some terminal color's borders left around the vim's overridden color scheme. How would I fix it.
Please check the image on this link. Stackoverflow doesn't allow uploading an image > 2Mb
You can't do that from Vim itself.
Terminal emulators use that padding to preserve readability when characters are displayed next to the borders of the window. The programs you run in your terminal have no knowledge of that padding and thus no ability to change it.
But you can read the documentation of your terminal emulator or take a look at its source code to find a way to enable/adjust/disable that padding.
FWIW, there's no way to change that in Terminal but it can be done for iTerm.
Alternatively, you could simply set the background color of your terminal to the one used in your vim colorscheme.
The image appears to depict behavior outside vim's control:
it is using a terminal emulator (could be xterm, could be some other).
the terminal emulator draws character cells on a window
those cells form a grid; the window may extend beyond the grid
the window can have a background color
the grid can have a background color
within the grid, most terminals provide some capability of drawing text with specific foreground and background colors
the grid can have a default background color which is not any of the specified colors
outside the grid, the window can also have a default background color
normally, the grid- and window-default backgrounds are the same
the window can be resized to (more or less) arbitrary sizes
the grid is constrained to exact character sizes
because of this difference, the window can have areas outside the grid which use its default color, and not match the grid's background color.
escape sequences which could affect the grid- and window-background colors are doing erases (see for example the ncurses FAQ My terminal shows some uncolored spaces).
though it is conceivable that erasures within the grid could affect those outside areas, doing that generally leads to odd visual effects.

Use arbitrary colors in Vim and terminator

I am working on terminal Vim colorscheme (for 256-color terminal) and I need a few dark colours that I could use as backgrounds. I'm not satisfied with ones available in standard palette - for example, color 22 (#005f00), the darkest shade of green, is still too bright.
I've read that terminal Vim does not allow specifying colors as RGB, so - to get arbitrary colors - I would have to tweak terminal emulator's color palette. Is there a way to tweak full 256-color palette in gnome-terminal / terminator? Preferences window only allows editing basic 16.
BTW, Chrome's hterm allows this via 'color-palette-overrides' preference (but has its own drawbacks).
Gnome-terminal doesn't offer a UI to alter the colors (apart from the first 16), but you can use escape sequences, e.g.:
echo -ne '\e]4;22;#004f00\a'
As you've mentioned, sometimes these colors get reset to their default values. This was a bug in the underlying VTE library, and got fixed in version 0.36.
As far as I know, you won't find a single terminal emulator that gives you that kind of control over the whole standardized xterm palette.
So, if you ever intend to share that colorscheme you are stuck with the default palette.
On the other hand, if that colorscheme is only meant for your usage or if you are OK with forcing a hard dependency on your users, you can use japh's colorcoke to generate an alternate palette more suited to your needs. See the repo's wiki for examples)

Are there conventions on which color combinations go well together?

Most terminal color palettes have colorschemes that are customizable.
Many terminal users make use of some standard colorscheme such as solarized.
I'm building a terminal application that needs to use colors.
My question is, how do I know which color combinations from the terminal color palette go well together?
For instance, in the colorschemes that I use, the last color in the palette generally serves well as an alternative background color, but I couldn't afford the risk that some text is hardly visible for someone else because of his different colorscheme.
Are there any conventions on this?

Solarized color scheme and palette distorts for ssh'd users in iTerm2

My setup includes vim, iTerm2, tmux, and the solarized dark color scheme. I have the dark solarized color palette loaded into iTerm2 (modifies the ansi colors) and do not use the degraded solarized color scheme (i.e., let g:solarized_termcolors=256) as talked about in the readme as an alternative to using the color palette. Everything looks great.
But, I often remote pair with co-workers. Folks ssh into my machine from other instances of iTerm2 and sometimes Terminal.app and create a new tmux session with my tmux session as their base/parent session. In the case of iTerm2, their setup does not include loading the solarized color palette (one uses another palette entirely) and setting the let g:solarized_termcolors=256 to use the degraded solarized color scheme. If that's what they want, great, but when they connect to me via ssh/tmux the colors are lost and often times distorted to the point of being illegible.
Is there any combination of settings, besides having everyone use the same settings, to remedy this? Right now the recommendation is for me to use the degraded color scheme and not load the solarized color palette so that the ansi colors are not modified. This does work, but leaves me w/ the degraded solarized color scheme. And as I prefer the non-degraded solarized color scheme, I'd prefer not to take this approach.
When used in a terminal, the solarized colorscheme for Vim defaults to 16 colors and depends on the palette of the terminal emulator because it uses "Red", "Yellow"… as values for ctermfg and friends.
If you want the same colors everywhere you obviously need to have the same palette everywhere because your "Red" may not be someone else's "Red".
I don't know what the author smoked when he wrote it but let g:solarized_termcolors=256 is not "degraded" at all compared to the default. The default uses only a palette of 16 colors (dependant on the terminal's palette, as we have already seen) while this option makes it use a terminal-independant 256 colors palette. Because the colorscheme is not dependant on the terminal emulator's palette anymore, the colors are actually "guaranteed" to look "good" and "the same" on your terminal emulator and on someone else's terminal emulator.
The catch is that your terminal emulator and their terminal emulators must support 256 colors. All of todays terminals do, but the default is often set to 16 colors. It's generally easy to turn 256 colors support "on", though.
But this option is Vim-only. The colors of your prompt or of the output of some commands or of tmux's TUI may still feel "off" to your co-workers.
The ability to customize the hell out of your setup is of course an important aspect of the Vim experience. But customization comes at a price. You get used to many little things and it could happen that, confronted to a vastly different setup, well… you just get lost. Or, as happens to you, your setup is customized to the point of being unusable by your co-workers.
Pair programming can only work if you and your pair are able to reach compromise on a setup. Obviously, this setup may not be exactly yours or his but you must find a middle ground on which everyone agrees for pairing to work. Because you and your pair may use different versions of tmux/vim, different shells or different terminal emulators, the safest bet is to use the most basic setup possible. Unfortunately for you, solarized is too fragile and far from being "basic" enough.

Why doesn't VIM recognize a color totally available?

This is mystery drives me crazy: I am trying to specify certain colors that are listed inside gVim 7.3 when running this script.
But when put in a .vim syntax file, gVim simply issues an error "Color name not recognized". This happens even with simple colors like orange. Instead, it only recognizes a few colors like red, blue, yellow, darkyellow, darkgreen, black, etc.
Why does this happen and how to workaround this?
Because, as a terminal program vim only supports ANSI colors by default.
http://en.wikipedia.org/wiki/ANSI_escape_code#Colors
I don't know enough about syntax files to fully answer, but these links might be useful
http://vim.wikia.com/wiki/256_colors_in_vim
http://vim.wikia.com/wiki/View_all_colors_available_to_gvim
It's possible that only the normal colors are available to syntax files from there you can use a different color scheme to reassign the normal colors.
http://vimcasts.org/episodes/creating-colorschemes-for-vim/
I ended up solving the problem by hard coding the offending color (orange) in the .vim file:
hi def MyOrange_color ctermfg=202 guifg=#ff5f00

Resources