3

If I create a file without an EOL, for example:

$ echo -n "1" > test

...and then open it in vim:

$ vim --clean test

...the left hand side of the statusline looks like:

"test" [noeol] 1L, 1C

Yet when I open the file with my own statusline there is no [noeol] flag. I cannot see any information in the docs for statusline about how to get this flag.

How should I configure my statusline to see this flag?

Many thanks!

Andy Stewart
  • 1,349
  • 8
  • 13

2 Answers2

2

I had thought that [noeol] was one of Vim's built in statusline flags, like [+] for modified. But @muru pointed out that it isn't; it's a message from Vim when you write a buffer (without an eol). This answers the question I thought I asked.

However if one does want to add [noeol] to the statusline then, as @ChristianBrabandt said, one can simply check the eol option and display [noeol] as appropriate. This answers the question I seem to have asked.

Andy Stewart
  • 1,349
  • 8
  • 13
2

You could check the value of endofline and display your statusline accordingly. For example, this shows [noeol] in your statusline when endofline is false:

set statusline+=%{&endofline?'':'[noeol]'}
Flux
  • 1,041
  • 1
  • 11
  • 25