用emacs编辑nginx, 一不小心格式化就会把nginx的配置文件弄得一团糟。
借助nginx.model吧。
首先下载
https://raw.github.com/ajc/nginx-mode/master/nginx-mode.el
让后放在某个目录下
之后编辑.emacs文件,添加几行:
(add-to-list 'load-path (expand-file-name "/opt/emacs_plugins/nginx/"))
(require 'nginx-mode)
然后重新启动Nginx,再打开nginx.conf或者其他配置文件,可以看到字符有颜色了。
然后将光标移动到某一行,执行命令:
nginx-indent-line
可以看到该行自动和上一行对齐。
虽然没有做到全选格式化,不过也算有一个方便的工具了。