Mars
Mars

Reputation: 8854

Turn on Vim plugins for some files, not others?

I recently added filetype plugin indent on to my .vimrc in order to enable special indenting and syntax highlighting for Clojure code (*.clj files). However, it's also causing indenting in my LaTeX files (*.tex). This is annoying when I'm editing, and even more annoying, because the tab characters that get inserted confuse a custom program I use to process my LaTeX files. I know I can make indenting use spaces, but I really just want "intelligent" LaTeX indenting to go away. Actually, I want all intelligent indenting to go away, except where I specifically ask for it.

How can I get correct auto-formatting for Clojure code in Vim, but turn off all special handling of LaTeX files (except for syntax highlighting)?

Sorry if this has already been answered; I haven't succeeded in finding the answer yet.

(Irrelevant editorial comment: Sometimes Vim "upgrades" make me want to go back to Unix 'vi'. OK, not really.)

Upvotes: 1

Views: 81

Answers (1)

Ingo Karkat
Ingo Karkat

Reputation: 172500

Each proper filetype plugin script has an inclusion guard at its beginning. If you don't want any of the filetype options for Latex files (i.e. filetype of tex), create a file ~/.vim/ftplugin/tex.vim with these contents:

:let b:did_ftplugin = 1

This causes the default ftplugin from $VIMRUNTIME to abort its execution. The same applies to indent: ~/.vim/indent/tex.vim and b:did_indent is the guard variable.

Alternative

On the other hand, if you just want to undo certain options (e.g. :setlocal expandtab to avoid inserting tabs), you'd put those overriding commands into the so-called after directory: ~/.vim/after/ftplugin/tex.vim.

Upvotes: 3

Related Questions