How to make a different background for different buffers in vim? And is it even possible? I tried to change the background color - it applies to all buffers, but I want something else. For example, depending on the type of file have a different background (shade).
2 answers
It is impossible to quickly do this with standard tools. For reasons of portability, Vim was designed as a console program to a terminal with 16 colors or even to a two-color console. GUI for him is just a minor, unimportant side effect.
Multicolored buffers with 16 available colors will just spoil the syntax highlighting. The maximum that can be done quickly is to come up with some kind of crutch to highlight the current line, to make the difference of the current buffer more obvious.
augroup BgHighlight autocmd! autocmd WinEnter * set cul autocmd WinLeave * set nocul augroup END - Instead of hiding / showing the cursor line, I use the AirLine plugin, it highlights the status line for the active buffer. Background wanted to use for buffers of different languages. - konofeev
- Understood, I can not help with anything, at best, again a crutch which determines the type of file and sets the corresponding color. Then open each file with a new process and then switch between them with the help of a tile window manager like i3 whose hotkeys coincide with normal Vim and enjoy life. But it's just a hellish crutch. - igumnov
In the standard package this is not possible - the colors are distributed to all buffers.
You can try changing colors when switching buffers. It will also change in non-active buffers, but will be restored upon return. b:colors_name best set to ftplugin / *. vim.
au BufEnter * if (exists("b:colors_name")) | let b:current_colors=colors_name \| execute "colorscheme " . b:colors_name | endif au BufLeave * if (exists("b:current_colors")) | execute "colorscheme " . b:current_colors | endif PS Here plugin tab colorsheme is very similar to the solution, only it is for tabs.
If you peep there, you can make your own something for buffers.