I want to install nginx-mode into emacs so that I can have highlighting and formatting of my nginx configuration files. What is the easiest way to do this?
How can I install nginx-mode into emacs?
1.4k Views Asked by Simon Woodside At
2
There are 2 best solutions below
0
On
If you can't use melpa:
You can download the file nginx-mode.el from https://github.com/ajc/nginx-mode and copy it in ~/.emacs.d/
Then in you .emacs you can add
(add-to-list 'load-path "~/.emacs.d/")
(autoload 'nginx-mode "nginx-mode" nil t)
(add-to-list 'auto-mode-alist '("nginx.conf\\'" . nginx-mode)) ;; or M-x nginx-mode
This requires
emacs24or newer.emacsnow has a pretty good package management system. The default package repositoryELPAhas a pretty restricted set of modes and packages, so instead we'll useMELPAwhich is actively maintained and growing.First, install
MELPA:Paste in this code: (from https://melpa.org/#/getting-started)
Save and exit.
Second, install
nginx-modeTo get nginx pretty-printing and indentation, do this to install nginx-mode:
Use
nginx-modeNow you can switch into nginx-mode with
M-x nginx-mode. E.g.:You can make it recognize the sites-enabled files automatically by looking at these instructions.