thedz
thedz

Reputation: 5572

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.

Upvotes: 12

Views: 5332

Answers (7)

learner
learner

Reputation: 391

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

Upvotes: 1

Joe Corneli
Joe Corneli

Reputation: 662

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

Upvotes: 1

Herbert Sitz
Herbert Sitz

Reputation: 22256

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/

Upvotes: 1

YuppieNetworking
YuppieNetworking

Reputation: 8851

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.

Upvotes: 2

VitoshKa
VitoshKa

Reputation: 8533

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:)

Upvotes: 7

dash-tom-bang
dash-tom-bang

Reputation: 17853

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.

Upvotes: 0

Trey Jackson
Trey Jackson

Reputation: 74460

For Emacs, you cannot do this. You can change the background for a frame only.

See the related questions:

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.

Upvotes: 0

Related Questions