简体   繁体   English

在Emacs或Vim中更改活动缓冲区/窗格的背景颜色

[英]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. 我通常在30英寸显示器上使用Vim和Emacs全屏工作,这意味着我往往会有很多分裂。活动窗格的模式行改变了Vim和Emacs中的背景,但有时这不是一个易于查看的活动窗格指示器。

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. 无论是Vim还是Emacs解决方案都可以。

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 . 有一种模式允许现在这样做,看看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. Vim与Emacs没有区别,因为在整个应用程序窗口中无法更改实际的背景颜色,Vim中的所有“窗口”必须具有相同的背景。 As dash-tom-bang says, though, the status line can be used to give some visual cue to which window is active. 然而,正如dash-tom-bang所说,状态行可用于为哪个窗口处于活动状态提供一些视觉提示。 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. 这是通过使用highlight命令将StatusLineStatusLineNC高亮组设置为具有不同颜色来完成的,活动窗口将具有StatusLine高亮颜色的状态行,并且所有其他窗口将具有'No StatusLineNC高亮显示。

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/ 还有txtfmt插件,它(尽管有一些误导性的截图)并没有真正让你拥有不同的背景,但是为了给窗口添加一些区别是有用的,有点笨拙,要求你在文本中添加标记字符: http//www.txtfmt.webs.com/

Mx package-install RET auto-dim-other-buffers RET . Mx 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 回复: https//github.com/mina86/auto-dim-other-buffers.el

For Emacs, you cannot do this. 对于Emacs,你不能这样做。 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. 一种选择可能是使用平铺窗口管理器 ,并使用一堆不同的Emacs帧。 And then you can use the FrameMove package to easily move between the frames. 然后,您可以使用FrameMove包轻松地在帧之间移动。

There are color schemes in Vim which make the status line really pop out. Vim中有一些配色方案可以使状态行真正弹出。 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. 在带有大量分割(和文件类型)的窗口中使用内置的colorschemes进行播放,您可以看到效果。 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. 我总体上讨厌它,但有一天会将这样的东西纳入我自己的颜色方案中。

It's possible, and very easy to do so with this 'highlight-focus' package : 使用这个“高亮焦点”套餐可以,而且非常容易:

https://github.com/kriyative/highlight-focus https://github.com/kriyative/highlight-focus

What I needed to do : 我需要做什么:

Mx package-install RET use-package RET. Mx package-install RET use-package RET。

Put the 'highlight-focus.el' in a folder emacs is looking. 将'highlight-focus.el'放在emacs正在寻找的文件夹中。

If needed put something like this in your .emacs: 如果需要,可以在.emacs中添加这样的内容:

(add-to-list 'load-path "~/.emacs.d/folder_with_lisp_files/")

Then in my .emacs : 然后在我的.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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM