0

How to view in Vim if there is any end of line character at the end of the file?

If file content is '1234' as by echo -n 1234 > file.txt Vim shows (with :set list option) '1234$'.

If file content is '1234\n' as by echo 1234 > file.txt Vim again shows '1234$'.

How do I distinguish between these two different contents if they are shown as same?

Is there any other way how to inspect EOL chars using Linux default tools?

2

The list option doesn't show that there is an EOL character at the end line, it shows where the end of the line is.

When the buffer is loaded you should see something like this in the first case (no EOL):

"file.txt" [noeol] 1L, 4C

and something like this in the second case (EOL):

"file.txt" 1L, 5C

Note the [noeol] in the first case and the different character count.

| improve this answer | |
  • I see. And writing to file in Vim will automatically place EOL to the end? Can this be disabled? – ps-aux Jan 20 '15 at 15:34
  • Yes but that would not be a very good idea. – romainl Jan 20 '15 at 15:36
  • I know. It was just out of curiosity. – ps-aux Jan 20 '15 at 15:38

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.