How to make VIM support Nginx .conf file syntax highlighting function

WBOY
Release: 2023-05-15 12:10:20
forward
876 people have browsed it

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 after login

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
Copy after login

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文件路径
Copy after login

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!