github email rss
SQL highlighting in Emacs
Feb 14, 2012
One minute read

At work I sometimes need to edit text files with sql procedures. This is how I got emacs (23) to highlight sql source files: If you do a simple search in Google, you will get many references to “sql.el”. Sadly, for a newbie like me in emacs, it’s not really clear which one to use (what version) or how to enable it. So,

1) Download this sql.el, and save it in your .emacs.d/site-lisp/ directory (or whatever you have in load path).

2) Add the following to .emacs to enable it to go into sql-mode whenever a specific file is opened:

(require 'sql)

(autoload 'sql-mode "sql-mode" "SQL Editing Mode" t)
      (setq auto-mode-alist
         (append '(("\\.sql$" . sql-mode)
                   ("\\.proc$" . sql-mode)
                   ("\\.sp$"  . sql-mode))

Change the file extensions to suit your needs. That’s it!

Back to posts