Hide Blank‑Line Markers in Vim and Neovim
In this article
- Background: Why Vim Shows Characters on Blank Lines
- How Vim/Neovim Renders Blank Lines
- Configuring listchars to Hide Markers on Empty Lines
- Using fillchars to Hide the Tilde Buffer Fill
- Alternatives: Plugins and Conditional Highlighting
- Common Problems and How to Fix Them
- Performance and Safety Considerations
- Frequently Asked Questions
Yes – you can stop Vim or Neovim from showing the default symbols on empty lines by adjusting the listchars and fillchars options, or by disabling list altogether.
Background: Why Vim Shows Characters on Blank Lines
Vim and its fork Neovim have a long‑standing feature called list mode. When :set list is active, the editor visualises otherwise invisible whitespace using the listchars option. Typical symbols include a dot for spaces, a special arrow for tabs, and a dollar sign ($) for the end‑of‑line. The end‑of‑line marker appears on every line, even on a line that contains no other characters. Because a completely empty line still terminates with a newline, the $ character is rendered, which many users interpret as a “blank‑line marker”.
Another visual element is the tilde (~) that fills the window past the end of the file. Those tildes are not part of the buffer; they are drawn by the fillchars setting and can also be customised or hidden.
How Vim/Neovim Renders Blank Lines
When list is on, Vim follows these steps for each line:
- Read the line from the buffer.
- If the line ends with a newline character, append the character defined by
listchars=eol:. The default is$. - If the line contains spaces, tabs or trailing spaces, replace each with the symbols defined in
listchars.
Because an empty line contains no spaces or tabs, the only visible symbol is the eol character. If you never enable list, Vim shows a completely empty line with no marker.
Configuring listchars to Hide Markers on Empty Lines
The most direct way to stop the $ from appearing on blank lines is to remove the eol entry from listchars. You can do this globally or locally in a filetype plugin.
- Open your
init.vim(Neovim) or.vimrc(Vim). - Add a line such as:
Notice thatset listchars=tab:▸\ ,trail:·,extends:»,precedes:«eolis omitted. - Enable list mode with
set listif you still want other symbols.
If you occasionally need the $ for debugging, you can toggle it on the fly:
:set listchars+=eol:$ " add back
:set listchars-=eol:$ " remove again
Because listchars is a comma‑separated string, you can add or remove entries without affecting the others.
Using fillchars to Hide the Tilde Buffer Fill
The tildes that appear below the last line are controlled by fillchars. To replace them with a space (effectively making them invisible) add the following to your configuration:
set fillchars=eob:
The key eob stands for “end‑of‑buffer”. Setting it to a single space removes the visible ~ characters. Some users also set fold: or vert: entries to customise other filler characters.
Alternatives: Plugins and Conditional Highlighting
If you prefer a more granular approach—show the end‑of‑line marker on non‑empty lines but hide it on truly empty lines—Vim’s built‑in options cannot distinguish the two cases. However, a few community plugins provide conditional rendering:
- vim‑blankline: Primarily draws vertical indentation guides, but it also offers an option
g:blankline_show_eolthat can be disabled. - nvim‑transparent: While its main goal is colour transparency, it includes a hook that can clear
listcharsfor empty lines via an autocmd. - Lua customisation: In Neovim you can write a small
autocmd BufEnter,InsertLeave *that checksgetline('.')and temporarily clearslistcharsfor that window.
These solutions require a bit of scripting and are optional; the built‑in method described earlier is sufficient for most users.
Common Problems and How to Fix Them
Even after editing listchars, some users still see a symbol on empty lines. Typical reasons include:
- List mode not enabled: If you omitted
set list, Vim will not uselistcharsat all, and the default behaviour (no markers) applies. Conversely, if you enablelistelsewhere (e.g., a filetype plugin) it may override your customlistchars. Use:verbose set list?to see where it was set. - Overriding plugins: Some colour‑scheme or UI plugins reset
listcharsonColorSchemeevents. Add your customisation after theColorSchemeautocommand, e.g.:autocmd ColorScheme * set listchars=tab:▸\ ,trail:·,extends:»,precedes:« - Terminal font limitations: If the symbol you chose for
tabortrailis not supported by the terminal, the terminal may fall back to a generic placeholder that looks like a dot on empty lines. Choose Unicode glyphs that are widely available, such as▸or·.
When troubleshooting, start by running :set listchars? and :set fillchars? to verify the current values. If they differ from what you expect, locate the source of the override with :verbose set listchars?.
Performance and Safety Considerations
Changing listchars or fillchars is a pure visual adjustment; it does not modify the buffer contents, so there is no risk of data loss. The only performance impact is a negligible increase in redraw time, which is imperceptible on modern hardware. However, if you write an autocmd that runs on every cursor move to toggle symbols, you could introduce noticeable lag. Keep any dynamic logic to the smallest possible scope (e.g., only on BufEnter or InsertLeave).
Frequently Asked Questions
Can I hide the $ only on completely empty lines?
No. The built‑in listchars option applies the eol character to every line that ends with a newline. To achieve line‑specific behaviour you would need a plugin or custom Lua/autocmd that temporarily clears listchars for that window.
Does disabling list also hide the tildes at the bottom of the window?
No. The tildes are controlled by fillchars, not by list. Use set fillchars=eob: to hide them while keeping list active for other whitespace symbols.
Will these settings work the same in both Vim and Neovim?
Yes. Both editors share the same listchars and fillchars implementations. The only difference is that Neovim often encourages Lua configuration; the same effect can be achieved with vim.opt.listchars in init.lua.
What if I want to keep the $ on non‑empty lines but not on blank ones?
You need a script that checks getline('.') for emptiness and temporarily disables listchars. A simple Neovim Lua snippet is:
vim.api.nvim_create_autocmd({"CursorMoved", "InsertLeave"}, {
pattern = "*",
callback = function()
if vim.fn.getline('.') == "" then
vim.opt_local.list = false
else
vim.opt_local.list = true
end
end,
})
This toggles the whole list mode, not just the eol character, but it satisfies the requirement for most users.
Do these changes affect how files are saved?
No. The visual markers are purely client‑side. When you write the buffer, only the actual characters in the file are saved; the $, dots, or tildes never become part of the file.
Can I revert to the default behaviour temporarily?
Yes. Use :set listchars+=eol:$ to add the end‑of‑line marker back, or :set list / :set nolist to toggle the whole feature.