Is it possible to not display a ~ for blank lines in Vim/Neovim?

Viewed 21444

Is it possible to not display a ~ for blank lines in Vim?

This confuses Mac Vim's scrollbar, and I quite don't like these tildes.

6 Answers

Vim 8.x:

You can now change the color just for the end of the buffer ~:

highlight EndOfBuffer ctermfg=black ctermbg=black

See changelog for Vim 8.x.

The tilde ~ characters are meant to remind the user that those lines are not part of buffer content.

The above highlight trick will hide the ~ character, but it is still there. For some terminals, this may not even work. If you happen to be a Neovim user, you can use fillchars option to change the end of buffer symbol like this:

set fillchars=fold:\ ,vert:\│,eob:\ ,msgsep:‾

This will use space instead of ~ for end of buffer, effectively hiding the annoying ~.

You may also be interested in discussions here.

For NeoVim, you can set the fillchars value for eob to a space character and that will effectively hide it. (This might not work for plain Vim).

In Lua (Nvim 0.5+):

vim.wo.fillchars='eob: '

In VimScript:

set fillchars=eob:\ 

Note: Calling the above will override your fillchars value for other items as well (if set), so use this as a reference to set multiple values together:

set fillchars=eob:\ ,fold:\ ,vert:\│

Or use set fillchars+=... to append it your existing values.

Related