Docsity

Visual Studio Tips: Boosting Productivity with Shortcuts and Features - Prof. Vicki H. All, Study Guides, Projects, Research of Computer Science

Toggle sidebar
bg1
Visual Studio Tips
Take some time to make your visual studio experience efficient.
1. Shortcuts
Go to definition F12
Find all references of a variable Shift F12
Go to declaration Ctrl F12
Go to previous location or forward location Ctrl hypen or Ctrl Shirt Hypen
Turn on intellisense Ctrl Space
Navigate backwards/forwards Use buttons on toolbar
Show Error List Ctrl backslash, E
Show Call Stack (when debugging) Ctrl Alt C
Toggle to Full Screen Shift Alt Enter
Find Ctrl F
Find in Files Ctrl Shift F
Find Symbol Results Ctrl Alt F12
Go to Line number Ctrl G
Surround with (if, region, for, try, …) Ctrl K, Ctrl S
Switch between tabs Ctrl Tab (back), Ctrl Shift Tab (forward)
Toggle Word wrap Ctrl R
Quickly navigate forward and backwards in the go to
definition stack.
Ctrl+Shift+7 Ctrl+Shift+8
Comment and uncomment lines of code
(note to comment you need the entire Ctrl K Ctrl C)
Ctrl K Ctrl C (to comment)
Ctrl K Ctrl U (to uncomment)
Incremental Search Ctrl I
2. Drag and drop code snippets
The Toolbox (Ctrl+Alt+X) window has multiple tabs. You can drag and drop code onto this window
and copy it elsewhere. Some tabs do not allow dropping code into them; those that allow will have the
appropriate icon.
pf3
pf4
pf5

Partial preview of the text

Download Visual Studio Tips: Boosting Productivity with Shortcuts and Features - Prof. Vicki H. All and more Study Guides, Projects, Research Computer Science in PDF only on Docsity!

Visual Studio Tips

Take some time to make your visual studio experience efficient.

1. Shortcuts

Go to definition F Find all references of a variable Shift F Go to declaration Ctrl F Go to previous location or forward location Ctrl hypen or Ctrl Shirt Hypen Turn on intellisense Ctrl Space Navigate backwards/forwards Use buttons on toolbar Show Error List Ctrl backslash, E Show Call Stack (when debugging) Ctrl Alt C Toggle to Full Screen Shift Alt Enter Find Ctrl F Find in Files Ctrl Shift F Find Symbol Results Ctrl Alt F Go to Line number Ctrl G Surround with (if, region, for, try, …) Ctrl K, Ctrl S Switch between tabs Ctrl Tab (back), Ctrl Shift Tab (forward) Toggle Word wrap Ctrl R Quickly navigate forward and backwards in the go to definition stack. Ctrl+Shift+7 Ctrl+Shift+ Comment and uncomment lines of code (note to comment you need the entire Ctrl K Ctrl C) Ctrl K Ctrl C (to comment) Ctrl K Ctrl U (to uncomment) Incremental Search Ctrl I

2. Drag and drop code snippets

The Toolbox (Ctrl+Alt+X) window has multiple tabs. You can drag and drop code onto this window and copy it elsewhere. Some tabs do not allow dropping code into them; those that allow will have the appropriate icon.

3. Previous cursor positions

Ctrl - This cycles you through the code positions you visited. Ctrl Shift - to navigate in the opposite direction.

4. Incremental search

To incrementally search for text as you type, first press Ctrl+i. Then type the word you want to search. Hit backspace to clear a character and enter to finish. Pressing F3 after this will work as usual, i.e. search for the next occurrence of previous search. Works without bringing up a search window.

5. Matching brace/comment/region/quote

Ctrl ] takes you to the matching brace. It also takes you to the matching comment, region or quote depending on what is at the cursor now.

6. Vertical block selection

Press Alt and then select the area you want with your mouse. Normally selection is horizontal (taking whole lines). This selects vertically.

7. Closing/Showing support windows

There are a bunch of necessary/useful windows in the Visual Studio IDE like Properties (F4), Solution Explorer (Ctrl Alt L), Output Window (Ctrl Alt O). However, they take up a lot of space. An easy way around this is to use the auto hide feature. Open the window you want to hide. Right click on its title and choose Auto Hide. The window will dock into the margin whenever your mouse is not hovering over it. This is really convenient as then they only take up room when you are using them.

8. Tab groups - group code editor windows

If you have many source code windows open, you can group them logically using tab groups. Right click the tab of the code window and choose New Horizontal Tab Group. This will move the window into a split window, allowing you to see both files. You can add more files to this new tab group and also move files back to the previous group by choosing Move To Previous Tab Group (by right clicking the tab of the code window).

9. Auto-complete

Press Ctrl Space or Alt RightArrow to auto-complete the word. Intellisense suggestions may pop up a window if there is more than one possibility.

 Fold/Unfold the current code block – Ctrl M, Ctrl M  Unfold all – Ctrl M, Ctrl L  Stop outlining – Ctrl M, Ctrl P  Fold all – Ctrl M, Ctrl O

15. Build and Debug

 Build – Ctrl Shift B  Run – Ctrl F  Debug - F  Cycle through build errors - F

16. Open header files

Right-click any filename in your source-code (i.e. in a string expression or #include line) and click "Open Document". Visual Studio will open the corresponding file in the IDE. This is nice if you wonder what things are defined in each header file.

17. Generate Browse Information

Select Generate Browse Info under the C/C++ project settings tab, for any source-files that you want to be included. This is very useful for searching for function definitions and declarations - just right- click a function / variable and select "Goto Definition Of..." and the IDE will take you straight there.

18. Refactoring – You have to buy Ref++ for refactoring support in C++. C# has it for

free. This will be useful to you in the future. I 'd bet you would agree that a significant part of any engineer's day is spent re-working existing code to become in some way 'better.' In many cases, 'better code' is a subjective term, but some common improvements include: adhering to OO-best practices, increasing type safety, improving performance, and increasing code readability and maintainability. Refactoring is a formal and mechanical process, used to modify existing code in such a way that it does indeed become 'better' while preserving the program's intended functionality. In addition to improving a program's overall design, the refactoring process tends to yield code which is far easier to maintain and extend in the long run. See http://msdn2.microsoft.com/en-us/library/ms379618(VS.80).aspx Refactoring support in .Net:  Extract Method This allows you to define a new method based on a selection of code statements.  Encapsulate Field Turns a public field into a private field encapsulated by a .NET property.  Extract Interface Defines a new interface type based on a set of existing type members.  Reorder Parameters Provides a way to reorder member arguments.

 Remove Parameters As you would expect, this refactoring removes a given argument from the current list of parameters.  Rename This allows you to rename a code token (method name, field, local variable, and so on) throughout a project.  Promote Local Variable to Parameter Moves a local variable to the parameter set of the defining method.