vimtricks.wiki Concise Vim tricks, one at a time.

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

  • filetype enables detection of file types
  • plugin loads filetype-specific plugin files
  • indent loads 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
  • :filetype shows the current filetype detection status
  • :set filetype? shows the detected type for the current file
  • :set filetype=python manually overrides detection
  • Filetype plugins live in ~/.vim/ftplugin/

Next

How do you yank a single word into a named register?