Highlight trailing whitespace with a shade of the current background color, so it always looks natural, regardless of a color scheme you're using. With a dark background (:h background
), the highlighting has a lighter shade, and with a light background, the highlighting has a darker shade.
The offsets of ctermbg
and guibg
colors in the Normal
highlight group are used as a shade of the background color.
By default, highlighting works only with listed buffers (:h buflisted
), so trailing whitespace won't be visible in help files or some plugin buffers.
Use string 'shrpnsld/trailing-shade.vim'
with your plugin manager and you're good to go.
Shade offset for TUI colors (:h tui-colors
). The range for this option is typically within 0..255
.
let g:trailing_shade_cterm = 8
Shade offset for GUI colors (:h gui-colors
). The format for this option is 0xRRGGBB
.
let g:trailing_shade_gui = 0x363636
While in Insert mode, highlight trailing whitespace occurring only after the cursor.
let g:trailing_shade_after_cursor = 1
Note for lazy.nvim users
These options should be set within the init
function when listing trailing-shade inside the lazy.nvim setup:
require("lazy").setup {
{ "shrpnsld/trailing-shade.vim",
init = function()
vim.g.trailing_shade_gui = 0x563636,
end },
}
:TrailingShadeOn
– turn on for all buffers.
:TrailingShadeOff
– turn off for all buffers.
:TrailingShadeOnHere
– turn on for current buffer.
:TrailingShadeOffHere
– turn off for current buffer.