Home > Article > Operation and Maintenance > How to make VIM support Nginx .conf file syntax highlighting function
Manual modification
Download the syntax file of the nginx configuration file: nginx.vim
wget http://www.vim.org/scripts/download_script.php?src_id=14376 -o nginx.vim
Copy the file to /usr/share/vim/vim74 /syntax
directory (it can also be a single-user directory ~/.vim/syntax/
).
Modify vim /usr/share/vim/vim74/filetype.vim
Add
au bufread,bufnewfile /etc/nginx/*,/usr/local/nginx/conf/* if &ft == '' | setfiletype nginx | endif
Note that you should modify the above command according to the nginx directory you installed
Automation script
#!/bin/bash mkdir -p ~/.vim/syntax && cd ~/.vim/syntax wget http://www.vim.org/scripts/download_script.php?src_id=14376 -o nginx.vim >/dev/null echo "au bufread,bufnewfile /usr/local/nginx/conf/* set ft=nginx" > ~/.vim/filetype.vim #其中路径/usr/local/nginx/conf/*为你的nginx.conf文件路径
Save the above code as a .sh file and run it in bash.
The above is the detailed content of How to make VIM support Nginx .conf file syntax highlighting function. For more information, please follow other related articles on the PHP Chinese website!