Some nice code editor features provided by the VS 2010 Power Tool Extensions

I’ve blogged in the past about the VS 2010 Productivity Power Tool Extensions – a free set of Visual Studio 2010 extensions that provide some nice additional functionality.

You can read my previous blog posts about it here and here.  In today’s post I’m going to briefly highlight a few small, but nice, code editor capabilities that are enabled when you install the free extensions (and which I didn’t highlight in my previous blog posts).

Ctrl+Click “Go to Definition”

One of the small, but useful, features that I find myself using a lot with the extensions is the "Ctrl + Click” go to definition feature. 

For those of you who haven’t tried it, it enables you to quickly navigate to the definition of a member or type within your code.  You can accomplish the same behavior out of the box with Visual Studio by right-clicking on a member/type and then choosing the “Go to Definition” context menu item – or by moving your cursor over a type/member and then pressing the F12 key.  But for some reason I’ve found the Ctrl+Click gesture provided by the VS 2010 Power Tool Extensions more natural and faster to use (since for my keyboard the F12 key requires a split-second extra finger move to use – whereas the control key is always in easy reach).

To try out the “Ctrl+Click” behavior, just hold down the “Ctrl” key and use your mouse to hover over a type or member in your code.  When the extension is enabled you’ll find that this causes a hyperlink to appear under each type/member you hover over:

image

Clicking the hyperlink will immediately navigate you to the definition of the type/member within your code:

image

Note that the “go-to-definition” feature in VS can also be used on a type that you don’t have source access to.  For example, like with the DbSet<T> collection I used in my EF “code-first” blog post yesterday:

image

When you click a type referenced from a binary library, VS will automatically generate a class definition based on the signature compiled into the assembly:

image

Triple Click Selection

Another one of the “small but useful” features provided with the power tool extensions that I find myself using a lot is the “triple click” feature. 

Today with VS you can double-click on a word to automatically select it:

image

When the “Triple Click” extension is enabled you can now also triple-click on a line to automatically select the entire line:

image

This behavior has been supported in Word for awhile.  Until I saw that there was a power tools extension for it I didn’t actually realize that VS didn’t already do it by default.  Well – now you can.

“Alt Up/Down Arrow” Line Movement

Another “small but useful” feature provided by the power tool extensions is the ability to easily move lines of code up/down within the editor. 

Simply select either a single line of code, or a block of multiple lines of code, within the editor:

image

Then hold down the “alt” key, and press either the up or down arrow on your keyboard.  This will cause the editor to move the selected code up or down within the editor (without you having to copy/paste or move anything around manually):

image

This is another one of those features that Word has had for awhile – and which is nice to now have in VS.

Column Guides

Column guidelines allow you display a vertical band within the code editor.  This is useful to help identify the maximum size a single line of text should be within your code (for example: to avoid wrapping when printing it out).

The power tool extensions enable you to add a column guide pretty easily.  Just cursor over in your code editor to where you want the guideline to be (note: you can see the exact line column count at the bottom of the editor):

image

Then right-click and choose the “Guidelines->Add Guideline” menu command:

image

This will then cause VS to show a column guide-line in all code editor windows at that column width – making it easier to see when you’ve written code or a comment that wraps beyond that:

image

If you want to remove a guideline, you need to move your editor cursor to be at the same column width as the guideline.  You can then right-click and use the “Guidelines->Remove Guideline” command to remove it.

Extensions Update

In case you missed it, the Visual Studio team last week made a minor update to the VS 2010 Productivity Power Tool Extensions to fix a few bugs and performance issues that people reported with the last release

Sean has a blog post with more details about the update here.  The update included fixes for:

  • Poor performance with Solution Navigator searches on large projects. In this revision, we've made some optimizations to the search algorithm. Search will also now only be initiated after two characters are typed in the search box.
  • Items in Solution Folders were not sorted.  In this revision, they are sorted alphabetically.
  • Invoking Quick Access could cause a crash on some machine configurations. This issue has been resolved in the current revision.
  • Ctrl+1 & Ctrl+2 were not configurable in the Solution Navigator, which blocked the ability to type @ on some keyboards. This revision provides the Edit.ShowSolutionNavigatorPopupForSelection & Edit.ShowSolutionNavigatorPopupForFile commands which can be rebound using Tools => Options => Environment => Keyboard.

If you have a previous build of the Power Tool Extensions installed you use the “Tools->Extension Manager” menu command, select the power tools extension and then click the “update” button to upgrade to the latest build. 

Summary

If you haven’t tried out the VS 2010 Productivity Power Tool Extensions yet, I’d encourage you to give it a try. It includes some nice additional functionality which can help save you keystrokes and time as you work within Visual Studio.  I’ve only covered a few of the features in this post and my previous two posts – there are a lot more cool things in there that I haven’t blogged about yet.

You can also now enable/disable each individual feature within the extensions pack – allowing you to selectively choose what you want to use.  Use the “Tools->Options” menu command, and navigate to the “Power Productivity Tools” tree-view item to enable/disable individual features.

Hope this helps,

Scott

P.S. In addition to blogging, I am also now using Twitter for quick updates and to share links. Follow me at: twitter.com/scottgu

33 Comments

  • nice tool, but the ctrl+click is easily clicked by mistake when copy and paste. Is there any solution for that?
    In the colorized parameter help tooltip, it cannot display the type of local variables, but the built-in tooltip contains this information. I think that shall not be problems to display the type, is there any option to show that?

  • Ahhh cool, stealing R# features, 1 feature at a time.

  • ctrl+click = most buggy feature ever. Try to select a code and copy that code with ctrl+mouse drag.

  • "Ahhh cool, stealing R# features, 1 feature at a time. "

    Of course, some of those features were in VisualAssist before C# had been invented, let alone R#.

  • I'm using Resharper so some of this functionality is overlapping, but I just love Solution Navigator and Searchable Add Reference Dialog.

  • I have to say the ctrl+click / copy paste overlap drives me crazy.

  • Is it possible may be in the future to have such option to change background in solution navigator/solution explorer?

  • The great thing about Alt+Up / Alt+Down is that you don't need to select the whole single line you want to move up or down - just make sure that the focus is in that line.

  • Ctrl+Click should let you use something other than ctrl. When copy and pasting then I always click before I let up on ctrl (on accident). I have to turn this feature off b/c of this. Also, the add reference dialog always gives me an exception dialog when closing it. Otherwise, good stuff!

  • I like the Ctrl-Click Go to Definition feature, but wish that it wasn't tied to Ctrl-Click. I often use Ctrl-Click to select an object/class name for copy/paste/rename. It would be great if we could define our own shortcuts for these features like we can for other commands in the Options dialog. Then I could map it to something like Alt-Click instead.

  • CTRL+Click stomps on an existing text editor feature: select word under cursor. For half keyboard, half mouse use (when you are a primary keyboard user and being forced to move the mouse), it's easier to CTRL+Click to select a word than double-click a word.

    You should have these customizable.

  • @mynkow, you can disable it in the settings. It's one of the first things I disabled since I used ctrl-click to highlight all the time. Scott, is there a way to reassign the ctrl-click to some other keycombo?

    -Morder

  • Love [most] of this stuff! But I don't like the automatic brace completion, so I turned it off. But it still seems to block me from hitting Shift-Enter and having the text proceed to the next line. I am often typing fast when I close a ) and start a { in which my finger stays on Shift during the ) + Enter + { and would like it to see the Enter. Any luck for me?

  • I've been absolutely loving this. It plus VS2010 Power commands have made the whole suite a wonderfully better experience. A couple things I'd really like to see if you can maybe mention to the team.

    1) In C#, after automatic brace parenthesis completion, if I hit ';' I want it to jump out of all the existing parenths to the end of the line and terminate it. The reason is, it's possible to be very deep with parenths with lambdas and casting and sometimes you've finished your statements. You can "tab" out, but hitting tab a couple times when all you want to do is terminate the lines seems difficult.

    2) Probably more appropriate for VS Power Commands, I'd like to be able right click on a tab or in a file and "Find in Solution Navigator" or "Find in Solution Explorer". When your projects are significantly large and you are using a lot of find in files or go to definitions, it's easy to loose track of the current file of interest.

    3) In the current release there appears to be a bug when you try and drag a pinned tab this crashes VS2010.

    Anyway, fantastic work by the team and thank you MS for investing in this effort. It shows continued support for developers out of band which is much appreciated.

  • @mynkow:
    Try the updated version; it now does the navigation on mouse-up, so ctrl-drag should work again.

    Other comments about rebinding ctrl-click:
    There isn't a way to do it in this release, sorry :( I can look into adding an options page for it in future releases.

  • Great

  • Love [most] of this stuff! But I don't like the automatic brace completion, so I turned it off. But it still seems to block me from hitting Shift-Enter and having the text proceed to the next line. I am often typing fast when I close a ) and start a { in which my finger stays on Shift during the ) + Enter + { and would like it to see the Enter. Any luck for me?

  • Love [most] of this stuff! But I don't like the automatic brace completion, so I turned it off.

  • one of the main problems with this tool pack is that it is not nearly customizable enough. for example, if every single keyboard/mouse binding was customizable, you wouldn't have any complaints about this-or-that feature hiding/blocking this-or-that VS/R#/whatever functionality.

    also, it would be nice if all power tool extensions related bindings were prefixed with something like "PowerTools" in the keyboard binding settings dialog, to make finding them easier. that way, i know that i'm editing the key binding for the extension, and nothing else. for example, rename Edit.ShowSolutionNavigatorPopupForFile -> PowerTools.Edit.ShowSolutionNavigatorPopupForFile.

  • Hi Scott, I think it would be nice to make some posts on VS Lightswitch. It seems an interesting subject to talk about and show its power and limitations.

  • Wow. Eclipse IDE has the ctrl+click and some of the other features since the middle ages. Of course, one can spend another ton of extra money and buy the resharper plugin. Microsoft loves your wallet.

  • check out Eclipse.. it has all these features (not to exagerate, i haven't seen the "add column marker" in Eclipse but i find it useless anyway), but they're not bragging about them. My point is, why do you guys so heavily promote absolute minor improvements, which aren't even by far original? They're a natural appearance in all major code editors and SDK's, and where they're not, they should be. Brag on. Losers.

  • I don't understand why MS is so far behind in providing useful features like this to developers. Similar features have existed in Java IDEs for years. I initially bought ReSharper precisely because it filled in these gaping productivity holes so well. I'm guessing that it's because MS focuses on point-click-stupid features and pretty GUIs that spit bloated, brittle code (EF 3.5 anyone?) instead of focusing on helping developers quickly *write* better code. I hope this changes.

  • Heh, pretty soon VS will have all the general capabilities that most tools, in combination with X Windows, have had for decades.

  • But is VS getting closer to NetBeans Java editor? Marking selection, showing last positions, auto-refactoring tips on side bar... Will it at last show multiple tabs in cross-reference frame?
    Changing between the two editors always makes me feel VS is more akin to Notepad...

  • You call these "nice code editor features"?! GOD!!
    I first started programming in Borland Turbo Pascal and Turbo C, then I met Visual Studio 2003 ... at that time I thought it was pretty cool but when I recognized other IDEs like Borland JBuilder, Netbeans and Eclipse, I found that Visual Studio is a pretty dumb IDE. Even after VS-2005 and VS-2008 (which I tried them) Visual Studio was still too weak compared to other free and open source IDEs (e.g. Netbeans).
    The features you mentioned above have been available in other free IDEs for several years (without installing any extra package) and of course they don't require using the mouse ... the mouse really slows you down.

  • completely agree with ACE, I remember working with eclipse 6 years ago and it had more features (out of the box), than VS and resharper combined together. VS is pretty powerful tool, but it has probably one of the worst code editors, damn marketing...

  • The only thing I want added to Visual Studio is the ability to highlight an interface and be able to search the solution for implementations of it.

    e.g.

    public void DoSomething(IWithAnInterface interParameter) // right click, find implementations
    {
    interParameter.CallMethod() // right click, find implementations of the IWithAnInterface.CallMethod()
    }

    Not being able to do that drives me mad.

  • Sounds Nice!

  • Cools tools...

  • It will be good to have clear all guidelines in the next realease.

  • Triple click? Really? Special extension to enable standard windows behavior in VS. Nice.

  • I disabled the ctrl-click becuase it would get confused with ctrl-v/ctrl-p/ctrl-x and the document I was working on was then unusable until I re-opened it (I kept getting 'Can`t go to definition' type messages).

Comments have been disabled for this content.