2

Inside of my editor (almost fresh install of neovim) there is no visual way to distinguish between a file that ends in a newline and a file that doesn't.

In my command line (zsh default?) there is a nice visual indicator that shows stdout didn't end in a newline:

enter image description here

The command output ends in a inverted-colors % percent sign.

I would like it if (neo)vim showed me a similar symbol at the end of the file if there is no ending newline.

For example, a % sign in the same style as the faded whitespaces in set list or ^M characters

enter image description here

How can I enable such a feature?

3

When opening a file w/o the last newline, Neovim (just as Vim) prints the message with the text "[noeol]" (or "[Incomplete last line]" depending on &shm option) included. Also, you can query it anytime with the command :set eol?

Another point is that Vim/Neovim will fix the missing newline upon file write automatically, if &fixeol is on (the default).

If you still want the visual indicator I suggest adding it to the status line instead. The exact instructions how to do this will differ depending on your status line plugin (or no plugin at all).

If you insist on adding the indicator into the buffer, I should admit I can't think of an easy way to add an extra character, but you'll still be able to add "a colored space" instead. For instance:

augroup no_eol | au!
    autocmd BufWinEnter * execute '2match' &eol ? 'NONE' : 'Visual /\%$/'
augroup end
| improve this answer | |
2

I don't know if it's possible to show it at the end of the line in question, but an alternative if you use a status line is to show that information in the status line. For example, :se statusline=%{&eol?'':'[noeol]'} will show [noeol] on the status line for the window showing the buffer with the "endless" line.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.