Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to override options set by ftplugins in vim

Tags:

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
like image 728
EvergreenTree Avatar asked Feb 06 '15 21:02

EvergreenTree


1 Answers

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.

like image 56
Ingo Karkat Avatar answered Sep 20 '22 18:09

Ingo Karkat