visual_studio.vim
Version 1.2
1 Overview
This document describes the visual_studio.vim plugin which interfaces Vim with Microsoft Visual Studio. Some highlights:
- The ability to control Visual Studio from within Vim
- Compatible with Visual Studio 2003, 2005 and 2008
- Load the current Visual Studio file into Vim
- Load the current Vim file into Visual Studio
- Build the solution, startup project or any project
- Compile a single file (C++)
- Access the project file hierarchy through Vim
- Switch between multiple running instances of Visual Studio
2 Installation
Requirements:
- Vim 7.0 or above
- Python 2.4 (Note: please install the version of python that vim was built with. For vim 7.0 this is python 2.4)
- Python for Windows extensions
Installation instructions
- Download the file visual_studio.zip. This contains the files visual_studio.vim and visual_studio.py.
- Unpack the files into your plugin directory, for example: $VIM/vimfiles/plugin.
3 Gui Operation
This section describes the operation of the visual_studio.vim plugin with gvim.exe. The main menu of the plugin is accessed through the menu bar of a gvim.exe session.

3.1 Get File
The Get File menu option will load the current Visual Studio file into Vim
3.2 Put File
The Put File menu option will load the Vim file into Visual Studio
3.3 Task List
The Task List menu option will display the task list of Visual Studio in the Vim quickfix buffer. Each line in the quickfix buffer corresponds to one task from the task list. The Visual Studio Task List typically lists compile errors that need to be fixed for a successful build.
The Vim quickfix commands can be used to navigate to any of the tasks in the list. For example the :cnext and :cprev commands can be used to cycle thru the entries in the quickfix window.
3.4 Output
The Output menu option will load the contents of the Visual Studio Output window into the Vim quickfix buffer. This is useful for accessing build information that is not included in the Visual Studio Task List.
3.5 Find Results 1 and Find Results 2
The Find Results 1 and Find Results 2 menu options will format the Visual Studio Find Results into a list in the Vim quickfix buffer.
3.6 Build Solution
The Build Solution menu option will trigger the building of the current Visual Studio solution. Vim will block until the build is complete. Then the build output results will be displayed in the Vim quickfix buffer.
3.7 Build Startup Project
The Build Startup Project menu option will trigger the building of the current Visual Studio startup project. Vim will block until the build is complete. Then the build output results will be displayed in the Vim quickfix buffer.
3.8 Compile File
The Compile File menu option will instruct Visual Studio to compile only the current Vim file. The file is opened in Visual Studio (if not already opened) and is compiled. Vim will block until the compilation is complete. Afterwards the output of the compile will be displayed in the Vim quickfix buffer. This menu option will only work correctly for C++ files.
3.9 Solutions
The Solutions menu option allows for the selection of the current Visual Studio instance. This option is useful for when multiple instances of Visual Studio are currently running and it is necessary to indicate which instance Vim should connect or "pair" with.
Initially the Solutions menu will be empty except for the Refresh option. Select the Refresh option to generate a list of running Visual Studio instances to choose from. Note: it could take a short time to retrieve the list of solutions. Status messages will be displayed in the message area indicating progress.
After selecting a running instance that instance is indicated with a leading asterisk.

Note: if there is only one instance of Visual Studio running it is not necessary to first select the instance before using any of the other visual_studio.vim commands. If no Visual Studio instance is specifically selected then the first (or only) running instance found is used.
As Visual Studio instances are started or stopped it is necessary to select the Refresh menu option to rebuild the Solutions selection menu.
3.10 Projects
The Projects menu option displays the projects submenus. Through the submenus it is possible to build the project in Visual Studio, select the project as the Startup Project, and navigate the file hierarchy of the project.
In the first level submenu the projects of the current solution are displayed. For the first use of the Projects menu it is necessary either to manually Refresh the menu or to have selected a solution in the Solutions menu. Note: it could take a short time to retrieve the project hierarchy. Status messages will be displayed in the message area indicating progress. If an incomplete project menu is displayed, it may mean that the menu is still being created.
The startup project is indicated with an asterisk.

Each project submenu has further submenus that are project specific. To load a file of the project into Vim select that file from the project submenu hierarchy.

If a file is added to or removed from the project in Visual Studio, it will be necessary to select the Refresh option to rebuild the Projects menu in Vim
4 Command Mode Operation
In addition to the pull-down menus of gvim.exe, the visual_studio.vim plugin can be accessed via command line (normal mode) mappings (ie shortcuts).
The mappings are defined in the visual_studio.vim file. The mappings depend on the Vim mapleader setting. In the following table the mappings are indicated with the default mapleader "/". Different mappings can be specified if desired.
Mapping | Action |
---|---|
/vg | Get the VS file into Vim |
/vp | Put the Vim file into VS |
/vt | Load the VS Task List into the Vim quickfix buffer |
/vo | Load the VS Output window into the Vim quickfix buffer |
/vf | Load the VS Find Results 1 window into the Vim quickfix buffer |
/v2 | Load the VS Find Results 2 window into the Vim quickfix buffer |
/vb | Build the VS Solution |
/vu | Build the VS Startup Project |
/vc | Compile the current file |
/vs | Select the current VS Solution instance |
/vp | Select the current VS Startup Project |
/va | About visual_studio.vim |
/vh | Online help - this page! |
5 Customization
Various settings of visual_studio.vim can be overridden. There are global variables (prefixed by g:) in the visual_studio.vim file that configure the plugin. Typically these will be be left as their default values but can be specified differently in a users .vimrc file for example.
Copyright (c) 2003-2007 Michael Graz