tips and tricks for using visual studio.net effectively

73
Microsoft Visual Microsoft Visual Microsoft Visual Microsoft Visual Studio.Net Studio.Net Studio.Net Studio.Net Tips Tips Tips Tips and Tricks and Tricks and Tricks and Tricks to save you 10 minutes a day to save you 10 minutes a day to save you 10 minutes a day to save you 10 minutes a day Wei Li 09/2006

Upload: weiliatslideshare

Post on 01-Nov-2014

5.854 views

Category:

Technology


1 download

DESCRIPTION

Some tips and tricks to use visual studio.net more productively and pleasantly

TRANSCRIPT

Page 1: Tips and Tricks for Using Visual Studio.Net Effectively

Microsoft Visual Microsoft Visual Microsoft Visual Microsoft Visual Studio.NetStudio.NetStudio.NetStudio.NetTips Tips Tips Tips and Tricksand Tricksand Tricksand TricksTips Tips Tips Tips and Tricksand Tricksand Tricksand Tricks

to save you 10 minutes a dayto save you 10 minutes a dayto save you 10 minutes a dayto save you 10 minutes a day

Wei Li09/2006

Page 2: Tips and Tricks for Using Visual Studio.Net Effectively

If I had eight hours to chop down a tree, If I had eight hours to chop down a tree, If I had eight hours to chop down a tree, If I had eight hours to chop down a tree, I'd spend six sharpening my axeI'd spend six sharpening my axeI'd spend six sharpening my axeI'd spend six sharpening my axe

- Abraham Lincoln

Page 3: Tips and Tricks for Using Visual Studio.Net Effectively

What do you What do you What do you What do you want most want most want most want most from from from from an IDE?an IDE?an IDE?an IDE?

It is just me -

Assist me write goodgoodgoodgood (hopefully) code fast fast fast fast andandandand happilyhappilyhappilyhappily

Page 4: Tips and Tricks for Using Visual Studio.Net Effectively

Let us make a great IDE Let us make a great IDE Let us make a great IDE Let us make a great IDE better better better better Launch VS.NET quicklyOrganize views and windowsChoose color scheme and fontChoose color scheme and fontMaster some shortcutsDo not repeat yourself using macrosExtend VS.NET using addinsUse command window

Page 5: Tips and Tricks for Using Visual Studio.Net Effectively

First thing first First thing first First thing first First thing first –––– save time on save time on save time on save time on start upstart upstart upstart upSay NO to the start page

Page 6: Tips and Tricks for Using Visual Studio.Net Effectively

Choose the right start up Choose the right start up Choose the right start up Choose the right start up optionoptionoptionoption

Show Start Page

Load last loaded solutionLoad last loaded solutionLoad last loaded solutionLoad last loaded solutionLoad last loaded solutionLoad last loaded solutionLoad last loaded solutionLoad last loaded solution

Show Open Project dialog box

Show New Project dialog box

Show Empty environmentShow Empty environmentShow Empty environmentShow Empty environment

Page 7: Tips and Tricks for Using Visual Studio.Net Effectively

Suppress the splash pageSuppress the splash pageSuppress the splash pageSuppress the splash pageIt probably does not bring you anything

good

Page 8: Tips and Tricks for Using Visual Studio.Net Effectively

Suppress the splash pageSuppress the splash pageSuppress the splash pageSuppress the splash page

Page 9: Tips and Tricks for Using Visual Studio.Net Effectively

Start VS.NET from command Start VS.NET from command Start VS.NET from command Start VS.NET from command promptpromptpromptprompt

C:> C:> C:> C:> devenvdevenvdevenvdevenv ////nosplashnosplashnosplashnosplash c:c:c:c:\\\\weiweiweiwei\\\\csharpcsharpcsharpcsharp\\\\proj1proj1proj1proj1\\\\proj1.slnproj1.slnproj1.slnproj1.sln

PrerequisitePrerequisitePut C:C:C:C:\\\\Program FilesProgram FilesProgram FilesProgram Files\\\\Microsoft Visual Studio .NET Microsoft Visual Studio .NET Microsoft Visual Studio .NET Microsoft Visual Studio .NET 2003200320032003\\\\Common7Common7Common7Common7\\\\IDEIDEIDEIDE\\\\ into your path

Page 10: Tips and Tricks for Using Visual Studio.Net Effectively

Set the pathSet the pathSet the pathSet the path

Page 11: Tips and Tricks for Using Visual Studio.Net Effectively

Litter your desktop with a Litter your desktop with a Litter your desktop with a Litter your desktop with a solution shortcutsolution shortcutsolution shortcutsolution shortcut

Double click it to open the solution

Page 12: Tips and Tricks for Using Visual Studio.Net Effectively

A little more about working A little more about working A little more about working A little more about working with command promptwith command promptwith command promptwith command promptC:\>devenv /?

C:\>devenv c:\wei\trial\csharp\unit_test\unit_test.sln /build DEBUG/build DEBUG

Why? Automation and continuous integration

Page 13: Tips and Tricks for Using Visual Studio.Net Effectively

Views, windows, layoutsViews, windows, layoutsViews, windows, layoutsViews, windows, layoutsSolution View Property ViewServer View…Debug WindowDebug WindowOutput WindowTask List Window…Oh My!

Page 14: Tips and Tricks for Using Visual Studio.Net Effectively

Less is moreLess is moreLess is moreLess is more

Ever tried Alt + Shift + EnterAlt + Shift + EnterAlt + Shift + EnterAlt + Shift + Enter?

Page 15: Tips and Tricks for Using Visual Studio.Net Effectively

Organize the views and Organize the views and Organize the views and Organize the views and windowswindowswindowswindowsMake views/windows auto-hide

Bring them back with shortcuts and Bring them back with shortcuts and command window aliases only when they are needed

Page 16: Tips and Tricks for Using Visual Studio.Net Effectively

Link file under editing to Link file under editing to Link file under editing to Link file under editing to solution explorersolution explorersolution explorersolution explorer

Page 17: Tips and Tricks for Using Visual Studio.Net Effectively

Link file under editing to Link file under editing to Link file under editing to Link file under editing to solution explorersolution explorersolution explorersolution explorer

Page 18: Tips and Tricks for Using Visual Studio.Net Effectively

Disable the navigation barDisable the navigation barDisable the navigation barDisable the navigation bar

Page 19: Tips and Tricks for Using Visual Studio.Net Effectively

Little thing countsLittle thing countsLittle thing countsLittle thing countsAdd guide lines to Visual Studio.Net Text EditorSubtle effect: do not write a line which is too long

Page 20: Tips and Tricks for Using Visual Studio.Net Effectively

Add guide lines to Visual Add guide lines to Visual Add guide lines to Visual Add guide lines to Visual Studio.NetStudio.NetStudio.NetStudio.NetText EditorText EditorText EditorText EditorOpen regeditNavigate to HKEY_CURRENT_USERHKEY_CURRENT_USERHKEY_CURRENT_USERHKEY_CURRENT_USER\\\\SoftwareSoftwareSoftwareSoftware\\\\MicrosoftMicrosoftMicrosoftMicrosoft\\\\VisualStudioVisualStudioVisualStudioVisualStudio\\\\<7.1><7.1><7.1><7.1>\\\\Text Text Text Text

EditorEditorEditorEditorRight-click on the Text Editor key and choose New String Value and name it

"Guides" Set the value of the guides to RGB(92, 46, 46) 80, 100

Page 21: Tips and Tricks for Using Visual Studio.Net Effectively

Text editor Text editor Text editor Text editor colorcolorcolorcolor schemeschemeschemeschemeCustomize a combination which is best for

your eyes

Page 22: Tips and Tricks for Using Visual Studio.Net Effectively

Anyone likes the dark side of Anyone likes the dark side of Anyone likes the dark side of Anyone likes the dark side of Visual Visual Visual Visual Studio.NetStudio.NetStudio.NetStudio.Net????

Page 23: Tips and Tricks for Using Visual Studio.Net Effectively

Text editor color scheme Text editor color scheme Text editor color scheme Text editor color scheme samplesamplesamplesample

Source: http://seizethedave.com/etc/idehttp://seizethedave.com/etc/idehttp://seizethedave.com/etc/idehttp://seizethedave.com/etc/ide----color.gifcolor.gifcolor.gifcolor.gif

Page 24: Tips and Tricks for Using Visual Studio.Net Effectively

Text editor color scheme Text editor color scheme Text editor color scheme Text editor color scheme samplesamplesamplesample

Source: http://www.codinghorror.com/blog/archives/000682.htmlhttp://www.codinghorror.com/blog/archives/000682.htmlhttp://www.codinghorror.com/blog/archives/000682.htmlhttp://www.codinghorror.com/blog/archives/000682.html

Page 25: Tips and Tricks for Using Visual Studio.Net Effectively

Text editor color scheme Text editor color scheme Text editor color scheme Text editor color scheme samplesamplesamplesample

Source: http://www.codinghorror.com/blog/archives/000682.htmlhttp://www.codinghorror.com/blog/archives/000682.htmlhttp://www.codinghorror.com/blog/archives/000682.htmlhttp://www.codinghorror.com/blog/archives/000682.html

Page 26: Tips and Tricks for Using Visual Studio.Net Effectively

Font for text editorFont for text editorFont for text editorFont for text editorChoose a font that works best for your

eyes

Page 27: Tips and Tricks for Using Visual Studio.Net Effectively

Font size for text editorFont size for text editorFont size for text editorFont size for text editorChoose a font size - I choose a larger font

size 14.

Why?Why?• Good for my eyes• Seeing a lot less code in the editor at a time helps

write better code. You naturally want see a whole method in one go. Seeing less code has the subtle effect of writing shorter and cleaner method.

Page 28: Tips and Tricks for Using Visual Studio.Net Effectively

ShortcutsShortcutsShortcutsShortcutsTons of themLots of them you never useLots of them you do not careLots of them you do not care

Master 10 – 15 killers that you use all the time

Page 29: Tips and Tricks for Using Visual Studio.Net Effectively

ShortcutsShortcutsShortcutsShortcuts

Ctrl + SpaceCtrl + SpaceCtrl + SpaceCtrl + Space

Complete the current word or shows all available methods and properties for a class

Ctrl + Shift + SpaceCtrl + Shift + SpaceCtrl + Shift + SpaceCtrl + Shift + Space

Show the parameter information when the cursor is inside method parentheses

Page 30: Tips and Tricks for Using Visual Studio.Net Effectively

ShortcutsShortcutsShortcutsShortcuts

Ctrl + K Ctrl + ICtrl + K Ctrl + ICtrl + K Ctrl + ICtrl + K Ctrl + I

Show a quick description about whatever object the cursor is currently resting on

Show a quick description about whatever object the cursor is currently resting on

Page 31: Tips and Tricks for Using Visual Studio.Net Effectively

ShortcutsShortcutsShortcutsShortcuts

Ctrl + M + OCtrl + M + OCtrl + M + OCtrl + M + OFold all code

Ctrl + M + PCtrl + M + PCtrl + M + PCtrl + M + PExpand all folds

Page 32: Tips and Tricks for Using Visual Studio.Net Effectively

ShortcutsShortcutsShortcutsShortcuts

Ctrl+K Ctrl+CCtrl+K Ctrl+CCtrl+K Ctrl+CCtrl+K Ctrl+CComment out the selected code area

Ctrl+K Ctrl+UCtrl+K Ctrl+UCtrl+K Ctrl+UCtrl+K Ctrl+UUncomment the selected code area

Ctrl+K Ctrl+FCtrl+K Ctrl+FCtrl+K Ctrl+FCtrl+K Ctrl+FFormat selected code area

Page 33: Tips and Tricks for Using Visual Studio.Net Effectively

ShortcutsShortcutsShortcutsShortcuts

F7F7F7F7Code view

Shift + F7Shift + F7Shift + F7Shift + F7Design view

Page 34: Tips and Tricks for Using Visual Studio.Net Effectively

ShortcutsShortcutsShortcutsShortcuts

F8F8F8F8Next item in the task list or search results.

Killer usage:Killer usage:Killer usage:Killer usage:Search for something in the whole solutionFrom command window: grep “wordtosearch”Then hit F8 for the results

Page 35: Tips and Tricks for Using Visual Studio.Net Effectively

ShortcutsShortcutsShortcutsShortcuts

F12F12F12F12Go to definition

Shift + F12Shift + F12Shift + F12Shift + F12

Go to reference

Page 36: Tips and Tricks for Using Visual Studio.Net Effectively

ShortcutsShortcutsShortcutsShortcuts

Ctrl + FCtrl + FCtrl + FCtrl + FFind

Ctrl + Shift + FCtrl + Shift + FCtrl + Shift + FCtrl + Shift + F

Find in files

Page 37: Tips and Tricks for Using Visual Studio.Net Effectively

ShortcutsShortcutsShortcutsShortcutsF5F5F5F5

Start with debugger

Ctrl + F5Ctrl + F5Ctrl + F5Ctrl + F5Start without debugger

Ctrl + F5Ctrl + F5Ctrl + F5Ctrl + F5Start without debugger

F10F10F10F10Step over

F11F11F11F11Step into

Page 38: Tips and Tricks for Using Visual Studio.Net Effectively

ShortcutsShortcutsShortcutsShortcuts

EscEscEscEscSet the focus back to code view (editor)

Ctrl + TabCtrl + TabCtrl + TabCtrl + TabGo to the next opened file in the text editor

Page 39: Tips and Tricks for Using Visual Studio.Net Effectively

And do not And do not And do not And do not forget forget forget forget

Ctrl + SCtrl + SCtrl + SCtrl + SSave the current fileNot just for VS.NET

Ctrl + Shift + SCtrl + Shift + SCtrl + Shift + SCtrl + Shift + SSave all modified files

Page 40: Tips and Tricks for Using Visual Studio.Net Effectively

And do not And do not And do not And do not forgetforgetforgetforgetShift + F10Shift + F10Shift + F10Shift + F10

= right clickBring up context menuIt works not only for VS.NETIt works not only for VS.NET

Page 41: Tips and Tricks for Using Visual Studio.Net Effectively

Create your own shortcutsCreate your own shortcutsCreate your own shortcutsCreate your own shortcutsToolsToolsToolsTools---->Options>Options>Options>Options---->Environment>Environment>Environment>Environment---->Keyboard>Keyboard>Keyboard>Keyboard

Page 42: Tips and Tricks for Using Visual Studio.Net Effectively

My customized shortcutsMy customized shortcutsMy customized shortcutsMy customized shortcutsalt + salt + salt + salt + s Solution viewer alt + calt + calt + calt + c Class viewer alt + palt + palt + palt + p Property Viewer alt + f alt + f alt + f alt + f Find File alt + o alt + o alt + o alt + o Opened file alt + o alt + o alt + o alt + o Opened file alt + aalt + aalt + aalt + a All members of the file alt + malt + malt + malt + m Methods of a file alt + valt + valt + valt + v Pending checking alt + ralt + ralt + ralt + r Output vieweralt + talt + talt + talt + t Options window alt + halt + halt + halt + h View history of the file under editing

Page 43: Tips and Tricks for Using Visual Studio.Net Effectively

ShortcutsShortcutsShortcutsShortcuts

List all shortcuts and print it out for reference

Use a macro available here:http://www.codinghorror.com/blog/archives/000315.htmlhttp://www.codinghorror.com/blog/archives/000315.htmlhttp://www.codinghorror.com/blog/archives/000315.htmlhttp://www.codinghorror.com/blog/archives/000315.html

Page 44: Tips and Tricks for Using Visual Studio.Net Effectively

MacrosMacrosMacrosMacrosA series of commands and instructions grouped

together

Automate repetitive actions Automate repetitive actions

Page 45: Tips and Tricks for Using Visual Studio.Net Effectively

MacrosMacrosMacrosMacros

Create a macro

Run a macroRun a macro

Edit a macro

Page 46: Tips and Tricks for Using Visual Studio.Net Effectively

MacrosMacrosMacrosMacrosAssign shortcut to a macro

Page 47: Tips and Tricks for Using Visual Studio.Net Effectively

MacrosMacrosMacrosMacrosCreate a command alias for a macro

Page 48: Tips and Tricks for Using Visual Studio.Net Effectively

AddinsAddinsAddinsAddins

All killers no fillersAll killers no fillers

Page 49: Tips and Tricks for Using Visual Studio.Net Effectively

VSFileFinder2003 VSFileFinder2003 VSFileFinder2003 VSFileFinder2003 Find files quickly in large solution with many projects

Freely available from:http://zerohttp://zerohttp://zerohttp://zero----oneoneoneone----zero.com/vs/zero.com/vs/zero.com/vs/zero.com/vs/http://zerohttp://zerohttp://zerohttp://zero----oneoneoneone----zero.com/vs/zero.com/vs/zero.com/vs/zero.com/vs/

A must

Page 50: Tips and Tricks for Using Visual Studio.Net Effectively

VSFileFinder2003VSFileFinder2003VSFileFinder2003VSFileFinder2003

Page 51: Tips and Tricks for Using Visual Studio.Net Effectively

USysWare DPackUSysWare DPackUSysWare DPackUSysWare DPackCode browseFile browseSolution browse

Freely available from:http://www.usysware.com/DPack/Default.aspxhttp://www.usysware.com/DPack/Default.aspxhttp://www.usysware.com/DPack/Default.aspxhttp://www.usysware.com/DPack/Default.aspx

Page 52: Tips and Tricks for Using Visual Studio.Net Effectively

USysWare DPackUSysWare DPackUSysWare DPackUSysWare DPack

Page 53: Tips and Tricks for Using Visual Studio.Net Effectively

USysWare DPackUSysWare DPackUSysWare DPackUSysWare DPack

Page 54: Tips and Tricks for Using Visual Studio.Net Effectively

USysWare DPackUSysWare DPackUSysWare DPackUSysWare DPack

Page 55: Tips and Tricks for Using Visual Studio.Net Effectively

USysWare DPackUSysWare DPackUSysWare DPackUSysWare DPack

Page 56: Tips and Tricks for Using Visual Studio.Net Effectively

QuickCode .NETQuickCode .NETQuickCode .NETQuickCode .NETWrite code for youGive you more time to code other things that you really

want to spend time on

Available from:http://www.dvxp.com/en/QuickCode.aspxhttp://www.dvxp.com/en/QuickCode.aspxhttp://www.dvxp.com/en/QuickCode.aspxhttp://www.dvxp.com/en/QuickCode.aspx

Page 57: Tips and Tricks for Using Visual Studio.Net Effectively

QuickCode .NETQuickCode .NETQuickCode .NETQuickCode .NET

Page 58: Tips and Tricks for Using Visual Studio.Net Effectively

QuickCode .NETQuickCode .NETQuickCode .NETQuickCode .NET

Page 59: Tips and Tricks for Using Visual Studio.Net Effectively

QuickCode .NET QuickCode .NET QuickCode .NET QuickCode .NET ---- DemoDemoDemoDemowritemainforprivate fieldprivate fieldcomments (div, ///)create NUnit test class

Page 60: Tips and Tricks for Using Visual Studio.Net Effectively

TestDriven.NETTestDriven.NETTestDriven.NETTestDriven.NETIntegrate NUnit to Visual Studio.NET

Quick Demo

Will be covered in another talk

http://testdriven.net/http://testdriven.net/http://testdriven.net/http://testdriven.net/

Page 61: Tips and Tricks for Using Visual Studio.Net Effectively

SolventSolventSolventSolventRecursive Expand/Contract

Open All Sub Items

Open Containing Folder In Windows Explorer

Command Prompt Here

http://www.paraesthesia.com/blog/comments.php?id=602_0_1_0_Chttp://www.paraesthesia.com/blog/comments.php?id=602_0_1_0_Chttp://www.paraesthesia.com/blog/comments.php?id=602_0_1_0_Chttp://www.paraesthesia.com/blog/comments.php?id=602_0_1_0_C

Page 62: Tips and Tricks for Using Visual Studio.Net Effectively

VIEMUVIEMUVIEMUVIEMUvi-vim emulation for Microsoft Visual StudioVi/Vim is an text editor which allows you to edit code

quickly

Not a freeware

Not for everyone due to its key binding

http://www.viemu.com/http://www.viemu.com/http://www.viemu.com/http://www.viemu.com/

Page 63: Tips and Tricks for Using Visual Studio.Net Effectively

VIEMU VIEMU VIEMU VIEMU ---- DemoDemoDemoDemoh j k l h j k l h j k l h j k l ---- move around quicklymove around quicklymove around quicklymove around quicklygg gg gg gg ---- go to the beginning of a filego to the beginning of a filego to the beginning of a filego to the beginning of a fileG G G G ---- go to the end of a filego to the end of a filego to the end of a filego to the end of a file:15 :15 :15 :15 ---- go to line 15go to line 15go to line 15go to line 15

yy yy yy yy ---- copy a linecopy a linecopy a linecopy a linep p p p ---- pastepastepastepaste

:w :w :w :w ---- save the filesave the filesave the filesave the file:q :q :q :q ---- close a fileclose a fileclose a fileclose a file:qa :qa :qa :qa ---- close all filesclose all filesclose all filesclose all files

:prb :prb :prb :prb ---- build the projectbuild the projectbuild the projectbuild the project

Page 64: Tips and Tricks for Using Visual Studio.Net Effectively

AddinsAddinsAddinsAddinsBring up addins using shortcuts and command aliases

This makes addins really powerful

Page 65: Tips and Tricks for Using Visual Studio.Net Effectively

Command windowCommand windowCommand windowCommand windowThe hidden treasure of VS.NET

Can be used to do pretty much everything

My control center for VS.NET

Page 66: Tips and Tricks for Using Visual Studio.Net Effectively

Command windowCommand windowCommand windowCommand windowWhat can you do from command window?

Bring up views, windowsBuild project and solutionBuild project and solutionSearch for something…You name it

Page 67: Tips and Tricks for Using Visual Studio.Net Effectively

Command window Command window Command window Command window ---- DemoDemoDemoDemoImportant: create a shortcut to bring up command create a shortcut to bring up command create a shortcut to bring up command create a shortcut to bring up command

windows firstwindows firstwindows firstwindows first

Mine is alt + walt + walt + walt + wMine is alt + walt + walt + walt + w

Page 68: Tips and Tricks for Using Visual Studio.Net Effectively

Command windowCommand windowCommand windowCommand window

Create alias

Page 69: Tips and Tricks for Using Visual Studio.Net Effectively

Command windowCommand windowCommand windowCommand window

List all aliases

Page 70: Tips and Tricks for Using Visual Studio.Net Effectively

Questions?Questions?Questions?Questions?

Page 71: Tips and Tricks for Using Visual Studio.Net Effectively

My question to youMy question to youMy question to youMy question to youWhat shortcuts, tips and tricks you use all the time?

Page 72: Tips and Tricks for Using Visual Studio.Net Effectively

Being productiveBeing productiveBeing productiveBeing productive

Tools matter but it is not only about tools. It is about a mind set.

Nobody has time for it. Make it. Dig it.It pays off.

Page 73: Tips and Tricks for Using Visual Studio.Net Effectively

If you save 10 minutes a dayIf you save 10 minutes a dayIf you save 10 minutes a dayIf you save 10 minutes a dayIs it a big deal?

Let us do the math:10 (minutes/day) * 300 (days)10 (minutes/day) * 300 (days)10 (minutes/day) * 300 (days)10 (minutes/day) * 300 (days)= 3,000 minutes= 3,000 minutes= 3,000 minutes= 3,000 minutes= 3,000 minutes= 3,000 minutes= 3,000 minutes= 3,000 minutes= 50 hours= 50 hours= 50 hours= 50 hours= One whole week= One whole week= One whole week= One whole week

Plus, chances are you will save more than 10 minutes a day!

Plus, you now can code in a better mental mood ☺