How do I enable automatic file type detection and plugins?
Answer
:filetype plugin indent on
Explanation
The filetype plugin indent on command enables three key features: file type detection, filetype plugins, and filetype-based indentation. This is essential for proper language support.
How it works
filetypeenables detection of file typespluginloads filetype-specific plugin filesindentloads filetype-specific indentation rules
Example
filetype plugin indent on
Now opening a .py file automatically sets Python syntax, indentation rules, and any Python-specific settings.
Tips
- Put this near the top of your vimrc
:filetypeshows the current filetype detection status:set filetype?shows the detected type for the current file:set filetype=pythonmanually overrides detection- Filetype plugins live in
~/.vim/ftplugin/