Frame Challenge : Using Vim "Properly"1
autocmd is NOT the solution to
filetype-dependent settings. It might seem like a good candidate at first, but Vim was built after the Unix philosophy of placing files in defined directory structure to affect behavior. Most vim users learn about vimrc first. But there are more (see
What this means for the OP is as follows : Tex
filetype-dependent settings, mappings, &c. should be placed in
~/.vim/ftplugin/tex.vim with the contents
to have Tex files get
spell on. Note I used
setlocal to make it buffer specific.
If you find that something in these files conflicts with other settings, you should place the offending line in
~/.vim/after/ftplugin/tex.vim to have it override any other settings.
Finally, make sure you at least enable filetype plugins with
filetype plugin on.
- I put "properly" in quotes because at times, when speaking about the Vim philosophy, I've been told its powerful configurability means there is no "right" way to use it. I disagree—I admit there are lots of creative ways to use a saw, but it was originally meant to cut things (wood mostly).
- The original version of this answer came from my own post here. I do not consider them explicit duplicates, however.