Sign in to follow this  

[.net] VS tips and tricks

This topic is 3867 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Alright, I'm sort of new to VS, but I'm wonderring if there is some place more seasoned VS users go to find tips and tricks for IDE? Or for that matter if anyone has any that they would like to share with a Newb to VS? Heck they could even wind up in the yet-to-be-published FAQs? Thanks, anyone, and everyone. (I suppose... it depends on how rediculous this question really is I guess.) L-

Share this post


Link to post
Share on other sites
When editing IDE toolbars, you can drag buttons and other controls onto the menu bar. I've used this trick to drag the few buttons I need, and then disable the rest of my toolbars for an uncluttered IDE.

Share this post


Link to post
Share on other sites
ctrl+shift+L -> delete a line of code

Check out the Refactor menu, it has a lot of neat stuff, like:
F2 -> globally rename a symbol (namespaces, classes, methods, variables, you name it, it can be renamed),

and,
Select block of code, ctrl+r, m -> extract block of code to a seperate method, figuring out the necessary parameters and return types along the way.


There are a lot of great features to VS, just poke around and try things out.

Share this post


Link to post
Share on other sites
You can also use the Decrease Indent and Increase Indent buttons to do the same thing (image posted below). These are slightly less obscure, but annoyingly hard to remember to use because of their size. Also, I don't know if they exist in all versions of Visual Studio, but I know they're in VS C# Express, meaning they're probably in VS C++ Express as well.

Indentbuttons

Share this post


Link to post
Share on other sites
Here's some:

ctrl-k-c to comment a selection of code

ctrl-k-u to uncomment a selection of code

Hold alt and drag a square of text, doesn't do whole lines like a regular drag selection.

MACROS FTW!

I developed some for class declarations and comment blocks etc.

Dave

Share this post


Link to post
Share on other sites
the code snippets are nice. Type "prop" (no quotes) and hit tab twice, it inserts a skeleton for a property, and the type, field name and property name are highlighted and you can jump from editing one to another by hitting tab again. Code snippets show up in the auto-completion list as a piece of paper with the bottom torn off. There's also "propg" for a read-only property, and most flow-control structures (if, for, foreach, do..while, etc.) have snippets that are the same name. Right click and select insert snippet to see the list.

also, you can use #region..#endregion blocks to define an area of code that can be collapsed in the editor which is handy for organizing stuff in large classes.

Share this post


Link to post
Share on other sites
You can add bookmarks to source files:

Ctrl+K, K to toggle a bookmark.
Ctrl+K, N to go to next bookmark.
Ctrl+K, P to go to previous bookmark.

The default bindings let you cycle through bookmarks across all files, which I actually find annoying. You can rebind them to only cycle through bookmarks in the current file.

Very useful if you're working with a large source file and need to edit several locations.

Share this post


Link to post
Share on other sites

This topic is 3867 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this