I have found several topics that come close to matching my issue but, does not completely solve my problem. I have read about, and tried researching, the .vim/ftplugin/ and .vim/after/ftplugin/ methods of dealing with several filetypes and additively changing the configurations. I have also tried overriding a ~/.vimrc config file with a ../ftplugin to no avail.
Question: What is the best solution for setting a default .vimrc iff one does not exist in the .vim/ftplugin/ directory? I have a standard vim configuration that I would like to apply if the filetype loaded is not one of which I have a filetype.vim configuration in the ftplugin directory.
Thank you.
There is not the filetype configuration, only individual options, mappings, etc. in ~/.vim/ftplugin/
, and defining a default depends on the particular type of configuration. The most common use case is buffer-local options, like 'softtabstop'
for example, and dealing with that is straightforward:
In your ~/.vimrc
, you define the global default via :set softtabstop=4
. Now if you don't want that for Java files, you put :setlocal softtabstop=0
in ~/.vim/after/ftplugin/java.vim
. Use of the after
directory is recommended because the default $VIMRUNTIME/ftplugin/java.vim
might set a filetype-specific default, and you'd override that this way.