Wparchive

Visual Studio – Reference hopping, code snippets, and other handy shortcuts

NOTE This is a Word Press Archive Post: Some of my posts from my original blog on WordPress have not been completely vetted for errors on this site. I am actively working, albeit slowly, on verifying these posts. Some may contain either missing images or broken links. Please bear with me while this transition is taking place.

Again, I’m posting another Visual Studio tip… this one is something I bet you have had experience with one or the other…

Tip of the Week

Reference hopping

When first using VS2010, I was glad to see that when I had the cursor on a variable name, class name, property name etc, it would highlight every other reference to that item in the document I was viewing. However, I missed the essential feature that corresponds to that highlighting. Reference hopping, (until I discover what the real name is, that’s what I’m calling it…) when you press Ctrl+Down/Up Arrow, the cursor jumps to the next reference to that item in your document, in the direction you specified, it also will wrap around when no more references are found in that direction.

clip_image001

Code Snippets

The next item I never see anyone use, but is clearly useful is code snippets. For example when writing a standard for loop, you might not want to have to type every step… try just typing “for” then hit Tab. VS will fill in the entire For loop, highlighting the iteration variable:

clip_image001[5]

By typing a new name for the “i” then hitting Tab again, it will update the rest of the “i” variables with the name you give… very handy.

clip_image001[11]

Some other really helpful items:

Keyboard shortcutResulting action
Shift+F12List references of item under cursor
Ctrl+]While on a scope enclosure: brace or bracket {,}, (, or ) will bring you to the matching brace.
Ctrl+spaceComplete the item under the cursor or bring up completion dialog
Ctrl+shift+spaceShow the param info for the method under cursor
Ctrl+K,IShows the definition for the item under the cursor
This post is licensed under CC BY 4.0 by the author.