Linux 系统下 VIM 或者 vi 编辑器默认是没有对 nginx 的语法高亮设置.
1. 下载 vi 语法高亮配置到 ~/.VIM/syntax, 如果不存在则创建该目录, cd ~/.VIM/syntax
wget http://www.vim.org/scripts/download_script.php?src_id=19394 -O nginx.VIM
2. 增加配置~/.VIM/filetype.VIM 到最后一行, 如果文件不存在则创建, vi ~/.VIM/filetype.VIM
- [root@chat-otc .VIM]# cat filetype.VIM
- au BufRead,BufNewFile /application/nginx-1.12.2/conf/* set ft=nginx
其中 / application/nginx-1.12.2/conf/* 为你的 nginx.conf 文件路径, 也可以写成 / application/nginx-1.12.2/*
3. 整体目录
- [root@hotcoin-chat-otc ~]# ll /root/.VIM/
- total 8
- -rw-r--r-- 1 root root 68 Dec 17 18:12 filetype.VIM
- drwxr-xr-x 2 root root 4096 Feb 5 10:51 syntax
- [root@hotcoin-chat-otc ~]# ll /root/.VIM/syntax/
- total 32
- -rw-r--r-- 1 root root 29541 Dec 17 18:11 nginx.VIM
来源: http://www.bubuko.com/infodetail-2945227.html