Emacs Visual Basic Mode

By Xah Lee. Date: ,

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: http://www.emacswiki.org/emacs/visual-basic-mode.el

As of , the latest version is: Version: 1.5 (2014-12-07)


After download, open the file, then type 【Alt+x eval-buffer】. Now, open any Visual Basic source code file, then type 【Alt+x visual-basic-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 file visual-basic-mode.el in the dir ~/.emacs.d/. Then put the following lines in your emacs init file:

;; 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

To make the code load and run slightly faster, you should byte-compile it. Call “byte-compile-file” and give the file name.

Thanks to Bruno Spinelli for a correction.