Reveal whitespace characters in visual mode, similar to VSCode.
GIF: Highlighting in charwise-visual and linewise-visual
To install the plugin with the default settings using Lazy:
{
'mcauley-penney/visual-whitespace.nvim',
config = true
}
visual-whitespace
comes with the following default settings:
opts = {
highlight = { link = "Visual" },
space_char = '·',
tab_char = '→',
nl_char = '↲',
cr_char = '←',
enabled = true,
excluded = {
filetypes = {},
buftypes = {}
}
},
visual-whitespace
defines the VisualNonText
highlight group. In the configuration, the highlighting settings you provide will constitute this highlight group. The highlight can also be set using Neovim's Lua API:
-- vim.api.nvim_set_hl(0, "VisualNonText", { fg = "#5D5F71", bg = "#24282d"})
-- vim.api.nvim_set_hl(0, "VisualNonText", { link = "Visual" })
visual-whitespace affords the following user-facing functions:
Lua | Description |
---|---|
require("visual-whitespace").toggle() |
Turn visual-whitespace.nvim off (toggles the enabled cfg flag) |
Use them in keymaps like:
init = function()
vim.keymap.set('n', "<leader>vw", require("visual-whitespace").toggle, {})
end
- This post on the Neovim subreddit, for doing a lot of the math for me
- aaron-p1/match-visual.nvim