[Tex/LaTex] When loading LaTeX files in vim (7.3) I get the error “perhaps you should insert a `~’ before ‘\ref’ “

vim

I have the over 30 errors in my LaTeX file, all over the \ref{...} command, and all following this similar pattern (I put it as a quote instead of code as it is long and code does not wrap)

I returned and saw under the sun, that the race is not to the swift,
nor the battle to the strong, neither yet bread to the wise, nor yet
riches to men of understanding, nor yet favour to men of skill; but
time and chance happeneth to them all. \ref{bible:ecclesiastes}

Every time I get the following complaint over \ref{...}

perhaps you should insert a `~' before "\ref"

Why am I getting this error? How can I avoid it?

Best Answer

If you write "... this was written by \ref{foo}" the following output is possible:

... this was written by
[1]

which looks ugly in fact of the linebreak. This is the reason why vim is very nice to you and told you that you should write: "... this was written by~\ref{foo}". Then your output is at least:

...  this  was  written 
by [1]

So it is not a LaTeX error, but an "error message" from vim.