Level up your VsVim

If you’re like me, you installed Visual Studio, installed VsVim, and then happily started coding. However, did you know that Visual Studio’s semantic understanding and manipulation of your code is exposed to VsVim?

For example, you might already know that pressing gd in VsVim will "go to the definition" of a method. But what if we want to "go to the implementation" e.g. through an interface to the underlying concrete method? The standard Ctrl-F12 requires some contortions, and maybe requires glancing down at your keyboard.

It’s easy to fix this; just add this mapping to your ~\_vsvimrc :

map gi :vsc Edit.GoToImplementation< CR >

Let’s break this down. The overall command is just a standard vim mapping, with the syntax :map {keys} {action} .

gi is the key combo we want to press.

is the key combo we want to press. Everything after that is the action that VsVim will execute: :vsc is VsVim’s Visual Studio Command runner Edit.GoToImplementation is a command exposed by Visual Studio. < CR > is a carriage return (i.e. pressing "Enter"), which executes the command.



Here are some similarly useful mappings:

map gr :vsc Edit.FindAllReferences< CR > map gp :vsc Edit.PeekDefinition< CR >

Adding your own mappings is easy:

Find a Visual Studio command you want to execute. You can explore the commands available in Visual Studio with the Command Window (View → Other Windows → Command Window), or by going to Tools → Options → Environment → Keyboard. Add that command mapping to your ~\_vsvimrc Reload the configuration by running :source ~\_vsvimrc