Speeding up the C# Source Code Editor

Sometimes, the C# source code editor feels a bit sluggish, even on pretty fast systems. One way to speed it up a little is by turning off the navigation bar (the drop down lists above the code window).

20060516_NavigationBarOn

  • “Tools” menu -> “Options”
  • “Text Editor” -> “C#”
  • Uncheck “Navigation bar” under “Display”

20060516_NavigationBarOff

Of course, the navigation bar is there for a reason and some people just can not live without it. But if you’re like me, and don’t use all the time, you may find the following macro for toggling the navigation bar helpful:

Sub ToggleCSharpNavigationBar()
    Dim objShowNavigationBar As EnvDTE.Property
    objShowNavigationBar = DTE.Properties("TextEditor", "CSharp").Item("ShowNavigationBar")
    objShowNavigationBar.Value = Not objShowNavigationBar.Value
End Sub

Installation:

  • Open the Macros IDE (“Tools” -> “Macros” -> “Macros IDE”)
  • Either create a new module or use an existing one (e.g. I have a module “Misc” where I collect all my small macros) and paste the code into it.

You could assign the macro to a hotkey (Tools -> Options -> Keyboard), but even though I use hotkeys a lot, for this macro I prefer an icon in a toolbar near the navigation bar:

  • Right click the toolbar area -> “Customize”
  • The “Customize” dialog opens
  • On the “Toolbars” tab: Create a new toolbar (e.g. "My Macros")
  • Drag the (floating) toolbar to the toolbar area and move it somewhere near the navigation bar.
  • On the “Commands” tab: Click the category "Macros"
  • Choose the macro (e.g. "MyMacros.Misc.ToggleCSharpNavigationBar") from the “Commands” list and drag it to the toolbar

The toolbar will look something like this:
20060516_Toolbar1

  • Copy the following image 20060516_ButtonImage to the clipboard
  • Back in Visual Studio, right click the macro name -> “Paste Button Image”
  • Right click the macro name -> “Default Style”
  • Right click the macro name -> “Name” -> Enter "Toggle Navigation Bar"
  • Close the “Customize” dialog

The button on the toolbar is now ready to use and will look like this:
20060516_Toolbar2

6 Comments

  • The navigation bar is indeed a slow piece of code. In large code files it can slow down everything that much that the editor can't keep up with the typing.



    Great tip on the macro btw :) I looked for a toggle in the keyboard setup but couldn't find any, didn't think of a macro to do it :). I'm not sure if I'll use it much though, the navigation bar is something that I use frequently so having it not there is slowing things down as well, but with a simple key combination bound to the macro, it's a matter of getting use-to I guess...



    I reported this slowdown in october, they are aware of the slowdown due to the navigation bar since that date though no fix has been made for this.

  • What a great solution....!

  • :-)



    Dont write the large files. It's a bad practice. Never had a problem.

  • It's a great solution to speed up your code editor. But I don't think that it costs anything. It's better to turn off all animations and intellisense or to use notepad-like editor at all if you want the real "speed".

    But there is a better solution to slow down editor by installing ReSharper and increase your coding speed.

  • VS editor is simply bad one...
    It needs a lot of work to be done to be comparable to let say Delphi or even Eclipse.

  • Good point on the speed.

Comments have been disabled for this content.