Changing the background color of the active buffer/pane in Emacs or Vim
I usually work fulls开发者_Go百科creen 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.
精彩评论