Different background shades in a single vim window - vim

In a single VIM window with 4 or 5 buffers for example, is it possible to give each buffer a different background shade?
Let's assume that the color theme is darkblue, I would like to make each buffer have a slightly different background shade of the dark blue.

No, the colorscheme settings are global.

You can do:
:hi ColorColumn guibg=#550000
and then color the background of selected windows with:
:setlocal colorcolumn=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256
Unfortunately this will only give you two shades (the one you set and the default), and colorcolumn's limit of 256 columns will break the illusion on very wide windows or long wrapped lines.
Thanks to blueyed for this tip.

Related

vim colorschemes not displaying properly

I'm running vim in the default Mac terminal and I'm trying to change the color scheme to one of the included color schemes, but none of them seem to be displaying properly.
For example, if I type :colorscheme blue, the colors change but there is a white border around the background.
Additionally, if I type :colorscheme desert, which is the color scheme I want to use, the syntax highlighting changes, but the background color does not.
Note that the desert color scheme is ostensibly supposed to look like this:
Why are these color schemes not displaying properly, and is there a way to fix them? Thanks!
vim's set background={light|dark} is not designed to change your background color, it is designed to work with your existing background color and give you colors that show up on that background.
Some colorschemes have multiple options to try and reproduce what the designers wanted in a variety of settings. For example, the colorscheme I am using has a base section with all the color settings followed by a 256 color specific section:
....
hi LineNr guifg=#465457 guibg=#232526
if &t_Co > 255
hi Normal ctermfg=252 " ctermbg=232
hi CursorLine ctermbg=234 cterm=none
...
which sets all the colors based on having a 256 color terminal, so that way people with 256 color terminals can still get close to what the colorscheme author intended, since a 256 color terminal cannot draw RRGGBB colors.
Likewise, colorschemes can respect background and change the colors they are using to be visible on that background color (so dark terminals don't have comments as dark blue, for example).
Lastly, vim only attempts to draw the background where it can draw characters, i.e., only the printable area of the screen. If your terminal width is, for instance, between 64 and 65 COLUMNS wide, then vim can only draw 64 characters, and there will be some space around the edges where vim doesn't try to draw, leaving the terminal's default background.
On Mac's Terminal.app, the easiest way to change your background color is to go to Preferences -> Profiles and either choose a default theme or edit the Background "Colors & Effects" section to be what you want.

How to change low contrast highlight in default vim color scheme

I am using vim with the default color scheme on dark background, but in many cases, the white font is highlighted with light pink color, making it hard to read. How do I fix this (change highlight color) in the default color scheme?
Here is an example of the problem:
You can override the colors displayed with the :highlight command, which can be called from your vimrc. The documentation is really quite good for this, and can be read here: http://vimdoc.sourceforge.net/htmldoc/syntax.html#:highlight.

How to change the folded part color on Vim

I fold some of the functions on my C code. When I fold them, the color becomes gray. Is there any way to change the color of folded part to another color?
You can use the :highlight setting. For instance, to set the background to red, add this to your .vimrc:
highlight Folded ctermbg=red
You can view a list of supported colour names by running :source $VIMRUNTIME/syntax/colortest.vim. ctermbg updates the console background; ctermfg updates the console foreground; and guibg & guifg update gvim's background and foreground colours. If you're changing gvim's settings, you can use whatever hex code you like (you don't have to restrict yourself to supported colours).
Type :verbose hi it will describe you all the highlighting groups and where they are defined. There is probably one describing the Fold but I don't know the group name by heart.

Paddings around the actual vim window in gvim

In gvim small paddings on the right and bottom sides of a window can appear. Particularly when gvim window is maximized. For example, here is what my bottom-right corner of gvim looks like when I maximize gvim window:
http://imgur.com/0lAYU
So is there anything I can do with these paddings? For example, move the actual editing area so paddings spread evenly from all four sides of gvim window instead of being only from two sides. Does any section of the manual contains the description of them? There is no real issue here, I'm just curious.
EDIT: I'm asking about the Linux version of gvim. I don't know how gvim behaves in similar situation in Windows or on Mac.
A common fix is to "hack" GTK so that GVim's window background is the same color as the background of your colorscheme. It's obviously less than ideal (you'd have to change it each time you try a new colorscheme) but it works reliably.
Put this code:
style "vimfix" {
bg[NORMAL] = "#202020" # this matches my gvim theme 'Normal' bg color.
}
widget "vim-main-window.*GtkForm" style "vimfix"
in this file:
~/.gtkrc-2.0
Put this in your .gvimrc:
set ghr=0
:help guiheadroom
'guiheadroom' 'ghr' number (default 50)
global
{not in Vi} {only for GTK and X11 GUI}
The number of pixels subtracted from the screen height when fitting
the GUI window on the screen. Set this before the GUI is started,
e.g., in your gvimrc file. When zero, the whole screen height will
be used by the window. When positive, the specified number of pixel
lines will be left for window decorations and other items on the
screen. Set it to a negative value to allow windows taller than the
screen.
I was tipped off to this solution on ArchWiki.
You can adjust the lines and columns options. For example:
:set lines=1000
:set columns=1000
You can find out about these with :help lines and :help columns.
Well, the reason it's there is because windows is forcing it to a size other than it's normal size plus an integer number of character sizes. As far as I know the people who wrote gvim didn't bother to add a centered option.

Changing the background color of the active buffer/pane in Emacs or Vim

I usually work fullscreen with Vim and Emacs on a 30" monitor which means I tend to have a lot of splits. The active pane's modeline changes background in Vim and Emacs, but sometimes that's not an easy to see indicator of the active pane.
Is there a way to change the background color of the active pane so I can easily, at a glance, see what split I'm currently in?
Either Vim or Emacs solution would be fine.
How about customizing the color of your active mode-line?
M-x customize-face RET mode-line
Change the background to "red" and the foreground to "white", and you won't be able to focus on anything else except you active buffer:)
Three years have passed since this question. There is a mode that permits to do this now, take a look at color-theme-buffer-local.
Vim is no different from Emacs in that the actual background color can't be changed within overall application window, all the "windows" in Vim must have same background. As dash-tom-bang says, though, the status line can be used to give some visual cue to which window is active. This is done by using the highlight command to set the StatusLine and StatusLineNC highlight groups to have different colors, active window will have status line with color of StatusLine highlight, and all other windows will have the 'No Cursor' StatusLineNC highlight.
There is also the txtfmt plugin, which (despite some misleading screenshots) doesn't really let you have different backgrounds, but it can be useful to give some added differentiating to windows, a little clunky by requiring you to add marker characters into your text: http://www.txtfmt.webs.com/
M-x package-install RET auto-dim-other-buffers RET.
"Visually makes non-current buffers less prominent"
Repo here: https://github.com/mina86/auto-dim-other-buffers.el
It's possible, and very easy to do so with this 'highlight-focus' package :
https://github.com/kriyative/highlight-focus
What I needed to do :
M-x package-install RET use-package RET.
Put the 'highlight-focus.el' in a folder emacs is looking.
If needed put something like this in your .emacs:
(add-to-list 'load-path "~/.emacs.d/folder_with_lisp_files/")
Then in my .emacs :
(use-package highlight-focus
:config
;; set the background of the mode-line
(setq highlight-focus:face 'mode-line
highlight-focus:face-property :background
highlight-focus:face-property-value "DarkMagenta")
;; set the background
(setq highlight-focus:face 'default
highlight-focus:face-property :background
highlight-focus:face-property-value "black")) ;; change color to desired value here
For Emacs, you cannot do this. You can change the background for a frame only.
See the related questions:
How can I change the background colour of a single emacs buffer?
Emacs custom background color by mode
One option could be to use a tiling window manager, and use a bunch of different Emacs frames. And then you can use the FrameMove package to easily move between the frames.
There are color schemes in Vim which make the status line really pop out. That's not exactly what you're looking for, but you may be able to make it work. Play with the built in colorschemes in a window with a lot of splits (and filetypes) and you can see the effects. I remember thinking that one in particular was god awful due to the change of the status line color, from inverse colors to something with bright yellow text in the active window. I hated it overall but one of these days will incorporate something like that into my own colorscheme.

Resources