planetp
planetp

Reputation: 16113

How to prevent Vim adding a newline at EOF for LaTex files?

When I edit a LaTex (.tex) file Vim automatically adds a newline at the end of file on write. How do I disable this behavior (just for .tex files)?

Upvotes: 1

Views: 321

Answers (1)

Matt
Matt

Reputation: 15196

That should be (almost) enough:

augroup mytex | au!
    autocmd FileType tex setlocal nofixeol
augroup end

But note that if some file already had a newline at the end, then that newline becomes "invisible" in Vim and you cannot remove it normally.

To deal with this you can use setl eol? and setl noeol manually, or simply add setl noeol to the autocommand.

See also embedded help system topics :h eol and :h fixeol.

Upvotes: 1

Related Questions