开发者

Syntax highlight a vimrc file in Emacs?

So, this might be a heretical question, but I'm looking for an Emacs mode that handles syntax highlighting of .vimrc files. This particular question has proved pretty hard to Google for the obvious reasons, but it seems extremely likely to me that someone would have written such a mode in the 20+ years of open warfare between the t开发者_如何学JAVAwo editors. Any ideas?


Googling does turn up wenbinye's vimrc-mode, a very lightweight generic mode. Here's what I have in my .emacs:

(define-generic-mode 'vimrc-generic-mode
    '()
    '()
    '(("^[\t ]*:?\\(!\\|ab\\|map\\|unmap\\)[^\r\n\"]*\"[^\r\n\"]*\\(\"[^\r\n\"]*\"[^\r\n\"]*\\)*$"
       (0 font-lock-warning-face))
      ("\\(^\\|[\t ]\\)\\(\".*\\)$"
      (2 font-lock-comment-face))
      ("\"\\([^\n\r\"\\]\\|\\.\\)*\""
       (0 font-lock-string-face)))
    '("/vimrc\\'" "\\.vim\\(rc\\)?\\'")
    '((lambda ()
        (modify-syntax-entry ?\" ".")))
    "Generic mode for Vim configuration files.")


There is a great package for this: https://github.com/mcandre/vimrc-mode

Install by M-x package-install vimrc-mode.

It highlights vimrc files with amazing syntax highlighting automatically when they are opened, or you can invoke it manually via (vimrc-mode).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜