Microsoft's Visual Studio Code is a free, redefined, cross-platform code editor that runs natively on OS-X, Linux and Windows. Visual Studio Code is a standalone, lightweight editor and should not be confused with Visual Studio's IDE.
Code offers the streamlined UI of a modern editor with rich code assistance, navigation and an integrated debugging experience. Visual Studio Code is optimized for developing modern web and cloud applications, so it offers extra tools for JavaScript, TypeScript, Node.js and ASP.NET 5, but has built-in support for multiple languages, including Visual Basic.
Code notable features include syntax highlighting, customizable keyboard bindings, bracket matching, snippets, IntelliSense, auto file saving, Git support with version control and themes!
Visual Studio Code is folder based, not project based. Unfortunately, at the time of writing this article (October 2015) VS Code can neither read nor write modules directly from Office macro-enabled files. You need to export all VBA modules into a single folder as text files and then open that folder in Code. All files in the opened folder are shown in the file explorer and become part of the workspace.
The VBA Toolkit add-in powered by Ribbon Commander offers a module commander menu for exporting, importing or deleting VBA and XML ribbon UI code in Office macro-enabled files.
Here is how the VS Code editor compares to the outdated VBE-IDE in Office
Code offers the streamlined UI of a modern editor with rich code assistance, navigation and an integrated debugging experience. Visual Studio Code is optimized for developing modern web and cloud applications, so it offers extra tools for JavaScript, TypeScript, Node.js and ASP.NET 5, but has built-in support for multiple languages, including Visual Basic.
Code notable features include syntax highlighting, customizable keyboard bindings, bracket matching, snippets, IntelliSense, auto file saving, Git support with version control and themes!
Visual Studio Code is folder based, not project based. Unfortunately, at the time of writing this article (October 2015) VS Code can neither read nor write modules directly from Office macro-enabled files. You need to export all VBA modules into a single folder as text files and then open that folder in Code. All files in the opened folder are shown in the file explorer and become part of the workspace.
The VBA Toolkit add-in powered by Ribbon Commander offers a module commander menu for exporting, importing or deleting VBA and XML ribbon UI code in Office macro-enabled files.
Here is how the VS Code editor compares to the outdated VBE-IDE in Office
Syntax Highlighting
I was saddened, but not surprised, when I realized that there is no build-in support for macro enabled files in Code. Office VBA code files (.cls, .bas, .frm) are opened without syntax highlighting in text mode by default. Select Visual Basic after clicking on the language mode indicator in the status bar.
You can extend the Visual Basic colorizer by modifying default Code settings as shown below, so that VBA files are opened automatically with Visual Basic syntax highlighting. You need admin rights in order to save the edited file.
Side By Side Editing
Up to 3 editors in any language e.g. VBA and XML can be opened side-by-side. Code differences (Diff) can be easily visualized when 2 files are compared side-by-side. To use the Diff tool, right-click each file and then click 'Select for Compare'
Editing Features
It is quite easy to view where a variable is used inside a VBA procedure or function: place the cursor next to a variable and Code will display indicators in the gutter. If no additional indicators appear, the variable may be declared, but not used in your program yet. That's a quick way to check for dead variables in your VBA code.
An example of IntelliSense and bracket matching using Ribbon Commander VBA in VS Code editor:
Code offers powerful search features. Strings found are shown in file explorer grouped by file. Click on a string to navigate to that particular line in the code pane. Results can be case sensitive, match an entire word or even be filtered by a regular expression!
How To Use Code Editor With VBA Projects
The Code editor cannot read VBA from Office macro-enabled files. Our VBA Toolkit addin powered by Ribbon Commander can export all modules from a VBA project to a single folder for editing or version comparison (Diff) with VS Code.