vim editor -> uncounted new line

Hi,

I entered the following text in a new file through vim: "Four score and seven years ago" saved and exit.

When I looked at the file size, it was 31B, although is supposed to be 30. I reedited the file (again with vim) to check for errors, but everything seemed fine. When I opened the file with smultron (just another text editor, if you wondered) I noticed there was a new line. Deleting this new line, solved the issue => file size =30B.

Once again I reopened the file with vim , without even going into "insert" mode, and closed it. The file was once again 31B.

What is happening ?

Thank you.

P.S. Using OS X 10.5

What do you mean by "closed it". I'll assume you saved, vs exiting without saving the file.

I think it's obvious. vim is adding a newline char to your file. The correct question would be _why_ is vim adding the newline to your file?

When you open the file in vim (use the same file), type :set fileformat & see if it says "unix" or "dos" -- if it says dos, that's why it's adding the file.

Check your .vimrc and see if it's set in there. Also, vim might be adding that setting based on your file extension. I've had a similar problem with vim automatically adding a newline (during my edit session) after 80 characters in length because my file extension was .txt.

I exited without saving.

it is unix

It has the same behavior regardless the extension.

my .vimrc only contains

set background=dark
set number 

P.S. Thank you for your answer. And yes you are right, I was wondering why vim does that.

Then it should not have written any extra data to your file at all, regardless.

If there's no newline char at all, vim will add one (but not if you exit without saving). I don't know if it's possible to not add it.

I misread your initial message as it keeps adding a windows formfeed char, instead of just a newline char.