# When loading LaTeX files in vim (7.3) I get the error “perhaps you should insert a ~' before '\ref' ”

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?

-

## migrated from stackoverflow.comDec 8 '11 at 19:50

This question came from our site for professional and enthusiast programmers.

Is this actually an error? Or is it just a suggestion that is output by vim? Is that the exact reference given? – Werner Dec 8 '11 at 18:57
@Werner it's actually an error. The exact error is |6 error| perhaps you should insert a ~' before "\ref" where 6 is the line number – puk Dec 8 '11 at 19:04
@derobert feel free to recommend moving this page. The reason I put it here, as opposed to TeX.SE is because I felt it was more a problem with vim's syntax check than LaTex's syntax. – puk Dec 8 '11 at 19:05
@puk: That's not default vim behavior. Maybe you've enabled a plugin (such as checksyntax) which is calling chktex? (and yes, I voted to move it; "latex editors" is explicitly given in the FAQ, so vim used for editing TeX would be OK there, I think ) – derobert Dec 8 '11 at 19:12
@puk: syntastic also does error checking for a variety of filetypes, including LaTeX. For LaTeX, it uses the lacheck script, which gives the error message. – Aditya Dec 9 '11 at 8:26

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.

-
LOL almost makes the migration from SO pointless – puk Dec 8 '11 at 20:32