If you enjoyed this site, please consider donating $3. Any amount is appreciated. Thanks!

Emacs Visual Basic Mode

Xah Lee, 2009-07-11

Emacs by default does not come with a Visual Basic mode. You can get visual-basic-mode.el by Fred White, Dave Love et al at: Source

As of 2009-07-11, the latest version is: “Version: 1.4.3 (Oct 8, 2008)”.

Install

The install instruction in the header file is not optimal. Here i give what i think is a better instruction.

After download, open the file, then type “Alt+x eval-buffer”. Now, open any Visual Basic source code file, then type “Alt+x visualbasic-mode”, you'll see the source code syntax colored.

To have emacs automatically load and use the mode when opening files ending in “.vb”, “.vbs” etc, put the following lines in your emacs init file (usually “~/.emacs”):

(add-to-list 'load-path "/path/to/parent/dir/") ;; make sure dir is the file's parent

;; autoload visual-basic-mode
(autoload 'visual-basic-mode "visual-basic-mode" "Visual Basic mode." t)
(add-to-list 'auto-mode-alist '("\\.vbs\\'" . visual-basic-mode)) ;VBscript
(add-to-list 'auto-mode-alist '("\\.vb\\'" . visual-basic-mode))  ;visual basic .NET file
(add-to-list 'auto-mode-alist '("\\.bas\\'" . visual-basic-mode)) ;visual basic form
(add-to-list 'auto-mode-alist '("\\.frm\\'" . visual-basic-mode)) ;basic language source
(add-to-list 'auto-mode-alist '("\\.cls\\'" . visual-basic-mode)) ;C++ class definition file

Related essays:

2009-06
© 2009 by Xah Lee.