EvergreenTree
EvergreenTree

Reputation: 2058

How to override options set by ftplugins in vim

I want to be able to set my own formatoptions for all filetypes, but I can't seem to get it to override Vim's default "ftplugins".

I put my custom formatoptions in .vim/after/overrides, but that doesn't seem to override anything.

If I run :verbose set formatoptions? it tells me that the last file to set that option was /usr/share/vim/vim74/ftplugin/vim.vim.

The contents of .vim/after/overrides.vim is:

" Format Options
set formatoptions=crnj

Upvotes: 12

Views: 3857

Answers (1)

Ingo Karkat
Ingo Karkat

Reputation: 172590

The after directory tree has the same structure as the one under ~/.vim/; your .vim/after/overrides.vim will never be sourced (check with :scriptnames).

You can't generically override all filetype plugins with the after directory, only individually, e.g. for Vimscript in ~/.vim/after/ftplugin/vim.vim.

You could do that generic override with an :autocmd Filetype * setlocal formatoptions=..., but that would have to be defined after the default filetype detection (i.e. :filetype plugin on).

You should use :setlocal instead of :set, just like in the ftplugins.

Upvotes: 21

Related Questions