Using Vim As Your C# Code Editor From Visual Studio

No, not through ViEmu or VsVim… I mean, actual honest to goodness Vim.

I’ve been working with Ruby for a not quite a year now (though, not much recently) and in that time I’ve tried a lot of editors and IDEs for ruby on Windows – including the Resharper-like RubyMine from JetBrains. RubyMine is a very powerful IDE with a lot of great refactoring tools built into it, etc. … but after all my experiments with the various ruby editors I find that the only thing I want is a good syntax highlighter and tree navigation. There are dozens of free editors out there that have this and a bunch of paid-for apps that also provide this in very convenient ways, including Vim with it’s many plugins.

Looking at my use of C#, though, I find myself constantly wanting Resharper to be around. Honestly, I think Resharper has made me a lazy developer with C# – and that’s probably a good thing in the world of C# with all of it’s syntax ceremony, etc. But I keep wondering to myself what would happen if I didn’t have that crutch to lean on and I went down to barebones Vim to do my C# coding.


Add Vim To Visual Studio’s Open With Option

I realize that I still want visual studio around for certain things, so I am not going to completely abandon it … yet… but I decided to do an experiment today and see what I could get away with and get away from, in my C# coding. I added gVim (the Windows Vim port) to my Visual Studio “Open With” options for my C# code files.

In Visual Studio 2008 (I’m currently doing Windows Mobile development, so I’m stuck with VS2008 for now) right click on a .cs file and selected Open With. You’ll get a nice dialog listing all the different options for .cs files. Click the Add button to add a new one.


Browse to your gvim.exe location with the “…” button and select it. The Friendly name will be populated automatically. Then hit OK. You’ll end up with Vi Improved in your Open With dialog box.


Now if you’re really brave, set this as the default. :) If you don’t want to set it as default (I don’t blame you… at least not until I’m more comfortable with this) you can just right click on a file and select Open With whenever you want to use Vim.


Stumble, Trip, Stumble, Trip

Of course I find myself stumbling and tripping and falling all over myself and vim when I’m editing C# files. I’m so used to Resharper being there to do everything for me that I find it very difficult to be productive. I don’t event have a good set of vim files for color coding my C# at this point, so that makes it even more ‘fun’. But I’m determined to see what I can do with Vim as my actual code editor… to face the problems that I run into and find solutions for them… to see if I actually need a micro-code generator like Resharper and find out if it really is just a crutch or if it is one of those necessary items because of the style of development that I engage in with C#. I’m hoping that I can find Vim plugins and syntax highlighting files that will help me solve the various problems that I run into, and that I can slowly replace more and more of my Resharper usage with Vim usage.

I don’t expect to give up Visual Studio any time soon, and I’m not sure that I’ll ever be able to get away from it completely… but we’ll see. I am hoping that over time I’ll rely less and less on Visual Studio and Resharper or at least come away from this experience with a better understanding of why I need them (if that’s the case).

… and now I’m off to find a good set of C# vim files.

About Derick Bailey

Derick Bailey is an entrepreneur, problem solver (and creator? :P ), software developer, screecaster, writer, blogger, speaker and technology leader in central Texas (north of Austin). He runs - the amazingly awesome podcast audio hosting service that everyone should be using, and where he throws down the JavaScript gauntlets to get you up to speed. He has been a professional software developer since the late 90's, and has been writing code since the late 80's. Find me on twitter: @derickbailey, @mutedsolutions, @backbonejsclass Find me on the web: SignalLeaf, WatchMeCode, Kendo UI blog, MarionetteJS, My Github profile, On Google+.
This entry was posted in .NET, C#, Productivity, Resharper, Vim, Visual Studio. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • I’ve found that a great way to really see what’s possible with Vim as an editor is to go try other’s dotfiles. There are a ton posted on Github and I learn something new about Vim every time I look at someone else’s settings.

    Also, not sure if you’ve seen this yet, but it blew me away with the capabilities that Vim can provide regarding refactoring, unit testing, etc while editing Python. Check out It’s amazing.

  • Plz post what ever you find so that we can see what you find (like David said above, there’s always more crazy-cool stuff to learn)
    btw, torte is the colorscheme that i use. (mainly b/c it’s buit in and easy)!stuff/vimrc.txt

  • I think this is a good think to try. I think somehow, although I am not quite sure I can put it into words, it will make you a better developer.

    I’ll say no more, because I don’t want to influence the results of the test. I want to hear what you learn though. You are brave!

  • Derick: If MSDN docs were only as easy to read as RDOC. :)

    David: Thank you for the link to that Kata. That was awesome.

  • Only hatred and fear lay down that path, Derick! Don’t let the dark side take a hold of you!

    I’ve been using gVim at work for my ruby work also, switching back into visual studio for my C# work. Resharper is, indeed, one strong motivator! But with Exuberant CTags, you can map an entire root folder and navigate to the definition of any class or method. What’s missing is a find usage functionnality. I installed grep for windows for that!

    Keep us informed! I should blog about my progress too… I always have more to say in comments than blog posts! :)

  • I tried a similar thing and blogged about it as I went. Some of this might be helpful for you:

  • Great post! I use the vividchalk color scheme and really like the NERDTree (project navigation) and SuperTab (autocompletion) vim scripts.

  • Craig

    I’ve heard good things about ViEmu. Have you looked into this as the solution to your problem?

  • Uchiha Itachi