Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax highlight a vimrc file in Emacs?

Tags:

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 two editors. Any ideas?

like image 517
Derek Thurn Avatar asked Nov 21 '10 07:11

Derek Thurn


1 Answers

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.")
like image 52
Gilles 'SO- stop being evil' Avatar answered Oct 11 '22 08:10

Gilles 'SO- stop being evil'