This is a plugin for Vim to dim inactive windows.
It provides two methods, which can be used independent:
With this method colorcolumn
gets set to a list containing every column for
the inactive windows, effectively resulting in a different background color
(see hl-CursorColumn
).
This is enabled by default and can be disabled, e.g. if you want to use the syntax method only:
let g:diminactive_use_colorcolumn = 0
Vim's ColorColumn highlighting group is being used for this, which is red by default, and pink if undefined):
:hi ColorColumn
ColorColumn xxx term=reverse ctermbg=1 guibg=DarkRed
You can define a custom color yourself, in case your colorscheme does not use something sensible:
:hi ColorColumn ctermbg=0 guibg=#eee8d5
There is an option to disable syntax highlighting for inactive windows. It is disabled by default, and you can enable it using:
let g:diminactive_use_syntax = 1
You can enable (un)dimming windows on Vim's FocusLost
and FocusGained
events by adding the following line to your .vimrc
(defaults to 0):
let g:diminactive_enable_focus = 1
NOTE: If you are using tmux it is recommended to install the
vim-tmux-focus-events plugin for Vim and add set -g focus-events on
to your ~/.tmux.conf
to enable better support for Vim's FocusLost
and
FocusGained
events in tmux.
The following commands are provided to control it:
-
DimInactive / DimInactiveOn
-
DimInactiveOff
-
DimInactiveToggle
-
DimInactiveSyntaxOn
-
DimInactiveSyntaxOff
-
DimInactiveColorcolumnOn
-
DimInactiveColorcolumnOff
Dimming can be controlled on the window level, which overrides any buffer-local configuration (a buffer can be displayed in multiple windows).
Disable for this window.
Enable for this window.
Reset config on window level.
Dimming can be controlled on the buffer level. This gets overridden by window-local configuration (a buffer can be displayed in multiple windows).
Disable for this buffer.
Enable for this buffer.
Reset config on buffer level.
You can disable the dimming based on buftype
or filetype
with the
following settings.
A list of buffer types where dimming gets disabled. Default:
let g:diminactive_buftype_blacklist = ['nofile', 'nowrite', 'acwrite', 'quickfix', 'help']
A list of filetypes where dimming gets disabled. Default:
let g:diminactive_filetype_blacklist = ['startify']
A list of buffer types where dimming gets enabled (overrides the blacklist). Default:
let g:diminactive_buftype_whitelist = []
A list of filetypes where dimming gets enabled (overrides the whitelist). Default:
let g:diminactive_filetype_whitelist = ['dirvish']
It is based on an idea from Paul Isambert, which got turned into a StackOverflow answer and then into a plugin, incorporating the suggestions made by joeytwiddle.
- It might slow down redrawing of windows.
- It will only work with lines containing text (i.e. not
~
(non-lines)).
- The cursorcross.vim plugin
provides automatic and "refreshingly sane
cursorcolumn
andcursorline
handling". - The ZoomWin plugin allows to (un-)maximize the current window.
- goyo.vim provides distraction-free writing in Vim.