visual_studio.vim

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:

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.

vs_menu_main.png

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.

vs_menu_solutions.png

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.

vs_menu_projects.png

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.

vs_menu_project_files.png

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.

Command mode mapppings
MappingAction
/vgGet the VS file into Vim
/vpPut the Vim file into VS
/vtLoad the VS Task List into the Vim quickfix buffer
/voLoad the VS Output window into the Vim quickfix buffer
/vfLoad the VS Find Results 1 window into the Vim quickfix buffer
/v2Load the VS Find Results 2 window into the Vim quickfix buffer
/vbBuild the VS Solution
/vuBuild the VS Startup Project
/vcCompile the current file
/vsSelect the current VS Solution instance
/vpSelect the current VS Startup Project
/vaAbout visual_studio.vim
/vhOnline 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

### 安装和配置 Visual Studio 中的 Vim 插件 #### 使用 VSCodeVim 扩展实现 Vim 功能 为了在 Visual Studio 中获得类似于 Vim 的编辑体验,可以考虑使用适用于 Visual Studio Code 的 `VSCodeVim` 插件类似的解决方案。虽然该插件专为 VS Code 开发,但存在针对 Visual Studio 的相似替代方案。 对于 Visual Studio 用户而言,推荐寻找专门设计用于此集成开发环境(IDE)内的 Vim 行为模拟扩展。这类工具允许使用者保留 Visual Studio 原有特性的同时享受到接近于 Vim 的键盘导航与命令执行效率[^2]。 #### 寻找并安装合适的扩展程序 进入 Visual Studio 后,可通过以下路径来查找所需的 Vim 风格扩展: - **菜单栏**: 访问 “Extensions” -> “Manage Extensions” 在此界面内利用搜索框输入关键词如 "Vim" 来定位目标扩展包。挑选评价良好且更新活跃的产品进行下载安装。 完成上述步骤之后重启 IDE 使更改生效。 #### 进一步自定义设置 部分情况下,新加入的功能模块或许会要求追加设定以满足个性化需求或是解决潜在冲突问题。例如调整快捷键映射或修改特定行为偏好等操作一般可在 `"Tools"` > `"Options"` 菜单下相应分类里完成[^3]。 此外值得注意的是,在初次接触此类增强型编辑器时可能会遇到某些默认绑定与其他系统级指令相悖的情况;此时建议查阅官方文档获取指导信息以便顺利过渡至新的工作流程之中[^4]。 ```csharp // 示例:C#代码片段展示如何查询已加载的扩展(仅作示意) using EnvDTE; using Microsoft.VisualStudio.Shell; public void ListLoadedExtensions() { DTE dte = Package.GetGlobalService(typeof(DTE)) as DTE; foreach (var ext in dte.ToolWindows.ExtensionManagerInstalled) { Console.WriteLine(ext.Name); } } ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值