On one of my Ubuntu computers, Vim has syntax highlighting for nginx config files while it does not on the other one. Looking at /usr/share/vim/vim80/syntax/
I see one has nginx.vim
while the other does not. Is there a simple command or repository I can use to retrieve and install syntax highlighting for nginx config files?
Debian-based distros have a long-standing tradition of separating Vim into several packages to 1) save a couple of megabytes and 2) annoy their users.
Assuming it's Ubuntu 22 you're using (the question doesn't say but it should be the same for other versions), the syntax file for nginx
is part of the package vim-runtime
. The more complete GUI versions of Vim like vim-gtk3
depend on vim-runtime
while the smaller vim-tiny
does not.
It has become one of my first steps on any Debian-based system to do
sudo apt-get install vim-gtk3
The amount of features pays off quickly even if the actual GUI version is never used.
This answers the first part of the question ("how to retrieve"), the second part ("load it in Vim") should be done automatically when Vim opens a file it detects to have filetype=nginx
.