Note that there are some explanatory texts on larger screens.

plurals
  1. POBest way to organize filetype settings in .vim and .vimrc?
    text
    copied!<p>I'm going through my vim dotfiles to tidy them up. I've noticed that through time I've added various filetype specific settings in various inconsistent ways. Let's suppose I'm customizing for Python:</p> <ul> <li><p><code>au BufRead,BufNewFile *.py (do something)</code>. I don't like this because some Python files might not have the .py termination. </p></li> <li><p><code>au FileType python (do something)</code>. This seems a better option because it doesn't depend on the file having the .py termination. The drawback is that Vim doesn't know about some filetypes. I can make Vim recognize additional filetypes, but I also have various inconsistent ways of doing it: a <code>.vim/filetype.vim</code> file, another in <code>.vim/after/filetype.vim</code> and various <code>set filetype</code> commands in <code>.vimrc</code>.</p></li> <li><p>Add a <code>.vim/ftplugin/python.vim</code> file with filetype specific settings. I understand the <code>$VIMRUNTIME/ftplugin/python.vim</code> can override whatever settings I make here. One problem is that I'm not sure how this interacts with <code>.vim/filetype.vim</code> and <code>.vim/after/filetype.vim</code>.</p></li> <li><p>Add a <code>.vim/after/ftplugin/python.vim</code>. I understand that this is loaded after <code>$VIMRUNTIME/ftplugin/python.vim</code> so it can overwrite settings from there. As in the previous method I'm not sure how it interacts with the <code>filetype.vim</code> files.</p></li> </ul> <p>So I have at least four ways of doing this, not mentioning syntax files and filetype-specific plugins. It seems to me the best way to do this is to put my filetype specific settings in <code>after/ftplugin</code> so they don't get overwritten, and <code>filetypes.vim</code> in <code>after</code> for the same reason.</p> <p>However, before I proceed I'd like to ask if anyone has suggestions about the best way to deal with filetype specific settings.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload