我想安装nginx-mode到 emacs 中,以便我可以突出显示和格式化我的nginx配置文件。什么是最简单的方法来做到这一点?
这需要emacs24或更新。
emacs现在有一个相当不错的包管理系统。默认包存储库ELPA有一组非常有限的模式和包,因此我们将使用MELPA积极维护和增长的模式和包。
MELPA:emacs /sudo::/etc/emacs/site-start.el
Run Code Online (Sandbox Code Playgroud)
粘贴此代码:(来自https://melpa.org/#/getting-started)
(require 'package) ;; You might already have this line
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/"))
(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize) ;; You might already have this line
Run Code Online (Sandbox Code Playgroud)
保存并退出。
nginx-mode要获得 nginx 漂亮的打印和缩进,请执行以下操作以安装 nginx-mode:
emacs
M-x package-list-packages RET (Type meta-key and S, then type package-list-packages and hit return)
C-s nginx RET (Type control-S to search, type nginx and hit return to find the nginx-mode package)
i (to mark it to install)
x (to execute installation of marked packages)
Run Code Online (Sandbox Code Playgroud)
nginx-mode现在您可以使用M-x nginx-mode. 例如:
emacs /sudo::/etc/nginx/sites-available/default
M-x nginx-mode RET
Run Code Online (Sandbox Code Playgroud)
您可以通过查看这些说明使其自动识别启用站点的文件。