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

How do I get syntax highlighting and indentation for every language in Vim without configuring each one?

Answer

vim-polyglot

Explanation

The vim-polyglot plugin is a curated collection of language packs for Vim that provides syntax highlighting, indentation, filetype detection, and compiler support for over 600 languages and file formats out of the box. Instead of manually installing individual language plugins for each technology you work with, vim-polyglot bundles them all into a single, lazy-loaded package.

How it works

Install vim-polyglot like any other plugin. Once loaded, it automatically handles filetype detection and applies the correct syntax, indentation, and compiler settings for any file you open — from mainstream languages like Python and JavaScript to niche formats like Terraform, Pug, and Prisma.

" Using vim-plug:
Plug 'sheerun/vim-polyglot'

" Using Vundle:
Plugin 'sheerun/vim-polyglot'

No further configuration is needed. Open any file and it just works.

Why not use Vim's built-in syntax files?

Vim ships with syntax files for many languages, but they are often outdated or incomplete. Vim-polyglot pulls from the best dedicated language plugins for each filetype and bundles them together, so you get:

  • More accurate and up-to-date syntax highlighting
  • Better indentation rules that reflect modern coding patterns
  • Filetype detection for newer formats that Vim does not know about natively
  • Improved folding support for many languages

Lazy loading

Despite bundling hundreds of language packs, vim-polyglot does not slow down Vim's startup. It uses lazy loading so each language pack is only activated when you actually open a file of that type. The startup cost is minimal compared to installing each language plugin separately.

Disabling specific languages

If you prefer a different plugin for a particular language, or want to use Vim's built-in support, disable that language in vim-polyglot before it loads:

" Must be set BEFORE the plugin loads (before plug#end() or similar)
let g:polyglot_disabled = ['markdown', 'go', 'python']

This tells polyglot to skip those languages entirely, leaving room for your preferred plugins.

What is included

Some of the popular language packs bundled in vim-polyglot:

Language Plugin source
JavaScript/JSX vim-javascript, vim-jsx-pretty
TypeScript yats.vim
Python python-syntax
Go vim-go-syntax
Rust rust.vim
Ruby vim-ruby
Terraform vim-terraform
Dockerfile Dockerfile.vim
GraphQL vim-graphql
TOML vim-toml
Markdown vim-markdown

Tips

  • Always set g:polyglot_disabled before the plugin loads in your vimrc — setting it after has no effect
  • Vim-polyglot does not include language servers or linting — pair it with ALE or an LSP client for diagnostics and code intelligence
  • If you use Neovim with treesitter, you may not need polyglot for syntax highlighting — treesitter provides more accurate highlighting via parsing. However, polyglot still provides useful indentation and filetype detection
  • The plugin is well-maintained with frequent updates as upstream language plugins release new versions
  • Check the full list of supported languages in the plugin's README — chances are your niche filetype is already covered

Next

How do I edit multiple lines at once using multiple cursors in Vim?