Emacs Visual Basic Mode

, ,

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: www.emacswiki.org

As of 2011-07, the latest version is: “Version: 1.4.12 (2010-10-18)”.

Install

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.

blog comments powered by Disqus