You are on page 1of 49

1.

To define a Destructor

~ + tab tab

Code snippet:

~_Default()

2. To create an Attribute

attribute + tab tab

Code snippet:

[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple =

true)]

sealed class MyAttribute : Attribute

// See the attribute guidelines at

// http://go.microsoft.com/fwlink/?LinkId=85236

readonly string positionalString;


// This is a positional argument

public MyAttribute(string positionalString)

this.positionalString = positionalString;

// TODO: Implement code here

throw new NotImplementedException();

public string PositionalString

get { return positionalString; }

// This is a named argument

public int NamedInt { get; set; }

}
3. Checked keyword

checked + tab tab

Code snippet:

checked

4. Creating a Class

class + tab tab

Code snippet:

class MyClass

5. Creating a Constructor

ctor + tab tab


Code snippet:

public _Default()

{}

6. Console.WriteLine() shortcut

cw + tab tab

Code snippet:

Console.WriteLine ();

7. Do..while loop

do + tab tab

Code snippet:

do
{

} while (true);

8. Else statement

else + tab tab


Code snippet:

else

{}

9. Enum

enum + tab tab


Code snippet:

enum MyEnum

10. Equals

equals +tab tab


Code snippet:
// override object.Equals

public override bool Equals(object obj)

//

// See the full list of guidelines at

// http://go.microsoft.com/fwlink/?LinkID=85237

// and also the guidance for operator== at

// http://go.microsoft.com/fwlink/?LinkId=85238

//

if (obj == null || GetType() != obj.GetType())

return false;

// TODO: write your implementation of Equals() here

throw new NotImplementedException();

return base.Equals(obj);

}
// override object.GetHashCode

public override int GetHashCode()

// TODO: write your implementation of GetHashCode() here

throw new NotImplementedException();

return base.GetHashCode();

11. Exceptions

exceptions + tab tab


Code snippet:

[Serializable]

public class MyException : Exception

public MyException() { }

public MyException(string message) : base(message) { }

public MyException(string message, Exception inner) : base(message,

inner)

}
protected MyException

System.Runtime.Serialization.SerializationInfo info,

System.Runtime.Serialization.StreamingContext context)

: base(info, context) { }

12. For loop

for + tab tab


Code snippet:

for (int i = 0; i < length; i++)

13. Foreach loop

foreach + tab tab


Code snippet:

foreach (var item in collection)

}
14. Reverse for loop

for + tab tab

Code snippet:

for (int i = length - 1; i >= 0 ; i--)

15. If statement

if + tab tab

Code snippet:

if (true)

}
16. Indexer

indexer + tab tab

Code snippet:

public object this[int index]

get { /* return the specified index here */ }

set { /* set the specified index to value here */ }

17. Interface

interface + tab + tab


Code snippet:

interface IInterface

}
18. Invoke- to safely invoke the event

invoke + tab tab

Code snippet:

EventHandler temp = MyEvent;

if (temp != null)

temp();

19. Iterator- simple iterator

iterator + tab tab

Code snippet:

public System.Collections.Generic.IEnumerator GetEnumerator()

throw new NotImplementedException();


yield return default(ElementType);

20. Iterator complex iterator

iterindex + tab tab

Code snippet:

public MyViewIterator MyView

get

return new MyViewIterator(this);

public class MyViewIterator

readonly _Default outer;

internal MyViewIterator(_Default outer)

this.outer = outer;
}

// TODO: provide an appropriate implementation here

public int Length { get { return 1; } }

public ElementType this[int index]

get

//

// TODO: implement indexer here

//

// you have full access to _Default privates

//

throw new NotImplementedException();

return default(ElementType);

public System.Collections.Generic.IEnumerator GetEnumerator()

for (int i = 0; i < this.Length; i++)


{

yield return this[i];

21. Lock statement

lock + tab tab

Code snippet:

lock (this)

{}

22. To Show the Message box in ASP.Net/Console Application

mbox + tab tab

Code snippet:

global::System.Windows.Forms.MessageBox.Show("hello");

23. Action
mvcaction +tab tab

Code snippet:

public ActionResult Action()

return View();

24. Action via http post method

mvcpostaction + tab tab

Code snippet:

[HttpPost]

public ActionResult Action()

return View();

25. For Namespace

namespace + tab tab


Code snippet:

namespace MyNamespace

26. Creating Property

prop + tab tab

Code snippet:

public int MyProperty { get; set; }

27. Attached dependency property

propa + tab tab

Code snippet:

public static int GetMyProperty(DependencyObject obj)

{
return (int)obj.GetValue(MyPropertyProperty);

public static void SetMyProperty(DependencyObject obj, int value)

obj.SetValue(MyPropertyProperty, value);

// Using a DependencyProperty as the backing store for MyProperty. This

enables animation, styling, binding, etc...

public static readonly DependencyProperty MyPropertyProperty =

DependencyProperty.RegisterAttached("MyProperty", typeof(int),

typeof(ownerclass), new UIPropertyMetadata(0));

28. Dependency property as a backing store

propdp + tab tab

Code snippet:

public int MyProperty

{
get { return (int)GetValue(MyPropertyProperty); }

set { SetValue(MyPropertyProperty, value); }

// Using a DependencyProperty as the backing store for MyProperty. This

enables animation, styling, binding, etc...

public static readonly DependencyProperty MyPropertyProperty =

DependencyProperty.Register("MyProperty", typeof(int),

typeof(ownerclass), new UIPropertyMetadata(0));

29. Property with full description

propfull + tab tab

Code snippet:

private int myVar;

public int MyProperty

get { return myVar;}


set { myVar = value;}

30. Auto implemented property with get accessor as private

propg + tab tab


Code snippet:

public int MyProperty { get; set; }

31. For int Main method

sim + tab tab

Code snippet:

static int Main(string[] args)

return 0;

32. Create structure

struct + tab tab


Code snippet:

struct MyStruct

33. Void Main method

svm + tab tab

Code snippet:

static void Main(string[] args)

{}

34. Switch stamen

switch + tab tab

Code snippet:

switch (switch_on)

{
default:

35. Test class

testc + tab tab


Code snippet:

[global::Microsoft.VisualStudio.TestTools.UnitTesting.TestClass]

public class MyTestClass

36. Test method

testm + tab tab

Code snippet:

[global::Microsoft.VisualStudio.TestTools.UnitTesting.TestMethod]

public void MyTestMethod()

37. Try..catch
try + tab tab

Code snippet:

try

{}

catch (Exception)

throw;

38. Try..finally

tryf + tab tab

Code snippet:

try

{}

catch (Exception)

{
throw;

39. Unchecked statement

unchecked + tab tab

Code snippet:

unchecked

40. Unsafe statement

unsafe + tab tab

Code snippet:

unsafe

41. Using statement


using + tab tab

Code snippet:

using (resource)

42. Dependency property event handler in windows work flow application

wde + tab tab

Code snippet:

public static

global::System.Workflow.ComponentModel.DependencyProperty

InvokeEvent =

global::System.Workflow.ComponentModel.DependencyProperty.Register(

"Invoke", typeof(EventHandler), typeof(_Default));

[System.ComponentModel.Description("Invoke")]

[System.ComponentModel.Category("Invoke Category")]
[System.ComponentModel.Browsable(true)]

[System.ComponentModel.DesignerSerializationVisibility(System.Compon

entModel.DesignerSerializationVisibility.Visible)]

public event EventHandler Invoke

add

base.AddHandler(_Default.InvokeEvent, value);

remove

base.RemoveHandler(_Default.InvokeEvent, value);

43. Dependency property in windows work-flow application

wdp + tab tab


Code snippet:

public static

global::System.Workflow.ComponentModel.DependencyProperty

MyPropertyProperty =

global::System.Workflow.ComponentModel.DependencyProperty.Register(

"MyProperty", typeof(string), typeof(_Default));

[System.ComponentModel.Description("MyProperty")]

[System.ComponentModel.Category("MyProperty Category")]

[System.ComponentModel.Browsable(true)]

System.ComponentModel.DesignerSerializationVisibility(System.Compone

ntModel.DesignerSerializationVisibility.Visible)]

public string MyProperty

get

return ((string)(base.GetValue(_Default.MyPropertyProperty)));

}
set

base.SetValue(_Default.MyPropertyProperty, value);

44. While loop

while + tab tab

Code snippet:

while (true)

Working in Full Screen Mode in Visual Studio

1. Alt+Shift+Enter is the shortcut to enter to fullscreen mode in Visual


Studio

2. Its sometimes really helpful and more appealing for developers to work
in full screen mode

Editing

1. For Copying a line in the IDE just go to the start of the line and press Ctrl+C,there is
no need to select anything
2. For Pasting a line just go to the start of the line and just press Ctrl+V
3. For Deleting a line just go to the start of the line and press Ctrl+X, this is not
actually delete but its similar to cut if you do Ctrl+X on current line and go to some
other place in your code and do Ctrl+V then it will paste the same line there.

Expanding and Collapsing the code units

1. This nice little shortcuts has saved me a lot of time.Whenever i am


working on a large piece of code i always get confused and make some changes in
other Method or property because they were looking similar.

2. But now with this shortcut i collapse one method as soon as it is


finished.

3. The shortcut is Ctrl+M+M.

4. Just go to the beginning or end of the method or property or any code


block and hit the shortcut it will expand or collapse the code block comparing to its
present state.

5. If you want to collapse all your code units or blocks to their definitions
then the shortcut to achieve this is Ctrk+M+O or Ctrl+M Ctrl+O.This is also a
very handy shortcut which helps a lot in development.

Automatic Text Indentation and Formatting

1. This shortcut helps me to write beautiful and decorative code which is easy to
understand by any person.
2. Shortcut is just press Ctrl+K+D.
3. This works not only in C# and VB code behind but it works well in aspx pages.
4. If you want to just format the selected piece of code then just press Ctrl+K+F .

Automatically adding Namespaces

1. Use the Ctrl+. (Remember this is Ctrl+[period] if you get confused)


shortcut key to automatically get intellisense for probable namespaces.
2. Just press enter to include the required namespace.
3. There are much cooler tricks when using a refactor like Resharper. I will
discuss those tricks later this month in one of my posts.
Commenting and Uncommenting the Code

1. This trick saved me a lot of time.


2. Just select the code to be commented and press Ctrl+K+C, this will
comment your code block.
3. For uncommenting the code just press Ctrl+K+U, this will uncomment the
code block.

Automatically generating properties

1. Generating dummy getter and setters or properties is also a pain in big projects.
2. Although i would recommend you some refactors like Resharper which can do it
for you or some code generators like Code Smith and also give a try to inbuilt on
in Visual Studio 2008 called T4 or Text Template Transformation Toolkit.
3. But if you don't have such a mass volume project and just don't want to write
your getter and setters then just type this prop + TAB+TAB
4. Remember you don't have to type all of this but you only type prop and then
press TAB two times for VS2008 to automatically generate the property for you
now you can change the name and any other thing by navigating and just
pressing TABS.

Increasing and decreasing the indentation

1. Select the code block for which you want to increase the indentation and after
selecting just press TAB, this will increase the indentation.
2. To decrease the indentation just select the required code block and then press
SHIFT + TAB, this will decrease the indentation of the selected code block.

Selecting a single word then line and then other lines within that block and
then.......

1. This is also a cool trick if you are in middle of something and want to do
something on either the word you are on or the entire code block, or entire
method, or entire class then just go on pressing Ctrl+W, it will start selecting for
you starting from the current word.
2. After selecting the desired code block you can perform any operation on
that code block.

Build & Debug Shortcuts and tricks

1. To build a solution just press Ctrl+Shift+B

2. To start debugging just press F5

3. To stop debugging just press Shift+F5

4. If you are already debugging or your WebDev.WebServer.Exe is


running or any other webserver is running you can directly attach to that
process escaping the hussle to build again this is a great time saver.Remember
always build or rebuild if you have done some major changes but if simply you
want to debug and have done no changes in any other class library projects
then you can use this trick

5. Simply Press Alt+D+P then the Attach to process window will open.

6. Simply choose your web server process to attach and you will see
without building your entire solution your solution has been attached to the
debugger

Find Options

1. You are already familiar with Ctrl+F option to find something either in
current documents or all open documents or entire project or entire solution,but
another find option is Ctrl+Shift+F, this trick is helpful when you want all your
results to be listed in a find window rather then to navigate one by one in every file
where the searched string exists.

Switching Between Design And Source Views

1. F7 is the key used to switch between design and source (ie c# or vb


files) views in IDE

2. If you want to just toggle the markup's design and source view or want
to view both then press Ctrl+PageDown

Some other common used shortcut keys which can be helpful

1. Ctrl+Alt+L for opening Solution Explorer


2. F4 for opening properties window
3. Ctrl+Alt+X for showing the toolbox
4. Ctrl+\+T for displaying the tasklist
5. Ctrl+\+E for displaying the error list

How to navigate between various opened tabs inside Visual Studio

Ctrl+TAB key will let you navigate between various open tabs in Visual Studio IDE

Going to Declaration and then again returning to the actual usage

Just press F12 to go to declaration

And press Ctrl+- to return back to the piece of code where you were earlier.
Selecting Source Control Plugin

1. If you are working in a team you probably will be using a source control there
are many options to choose SVN,Visual SVN,TeamFoundationServer,Source Vault and
Source Fortress and many others.

2. But when selecting a client you have to mention it in Source Cotrol Plugin
Selection as shown below
I want solution for every project which i create

1. If you want a solution for every project which you create then you have to
enable this as shown below
1. CTRL + "K" + "M":
Incase you need to add a method to an
already existing class you just write the method
as if it exists :

1: int i = 5;
2: bool flag = NewMethod(i);

Click on the shortcut and you will get the

following method stub:

1: private bool NewMethod(int i)


2: {
3: throw new NotImplementedException();
4: }

2. CTRL + ".": This one expands the one before it, say you need to add a functionality
to a different class. again all you have to do is use the method as if it exists:

1: int i = 5;
2: bool flag = DifferentClass.NewMethod(i);

Put the cursor on the new method, click the shortcut and you will see this:
Hit Enter and you will get a new method stub with the return value and the parameter,
in the other class.

1: public class c
2: {
3: internal bool NewMethod(int i)
4: {
5: throw new NotImplementedException();
6: }
7: }

3. CTRL + "-" and CTRL + SHIFT + "-": These two are similar to the Forward and
Backwards buttons of the WebBrowsers and will take you to all the places your curser
was, Very useful for those times you click F12 to go to definitions and then have no
clue where you were before :).

4. ALT + ENTER: We talked about it in the last post, but it seems that this shortcut will
open the properties window on anything that moves, even Files in your Windows
Explorer.

5. SHIFT + ALT + ENTER: This one will switch you Visual Studio to Full Screen
mode, which is very useful in those boring presentation when you have to show your
code through a projector on a screen. Another click will get you back to normal mode.
6. CTRL + "M" + "M": This one will collapse the region your cursor is at whether its
a method, namespace or whatever for collapsing code blocks, regions and methods.
The first will collapse only the block/method or region your cursor is at while the
second will collapse the entire region you are at.

7. CTRL + ALT + "P": This will open up the attach to process window, very useful for
debugging.

8. CTRL + "R" + "R": This one is used to quickly rename a method/ variable or
whatever.
9. F8 and SHIFT + F8: These two are great! they are similar to the shortcut number 3
but they will take you forward and backwards in your search results just search for
something and then start hitting F8 and you will see.

10. CTRL + SHIFT + "B": This one will invoke build solution.

11. CTRL + "B" + "T": This one will allow you to quickly add or remove a bookmark
from a line of code.

General Shortcut Keys

ShortCut Description
Ctrl-X or Shift-
Cuts the currently selected item to the clipboard
Delete or Ctrl-L
Ctrl-Del Delete next "word"
Ctrl-C or Ctrl-
Copies the currently selected item to the clipboard
Insert
Ctrl-V or Shift-
Pastes the item from the clipboard at the cursor location
Insert
Ctrl-Z or Alt-
Undo the previous editing action
Backspace
Ctrl-Space To see intelligence dialog
Ctrl-Y or Ctrl-
Redo the previous undo action
Shift-Z
Ctrl-S Saves the current selected file
Ctrl-Shift-S Saves all files and projects
Ctrl-P Displays the Print dialog

F7 Switches from the design view to the code view in the editor

Shift-F7 Switches from the code view to the design view in the editor

Shift-F8 or F8 Navigate to compile time errors


Alt-Shift-A Add Existing Item(file) to selected project
Ctrl-Shift-A Add New Item(file) to selected project
Display the selected item quick output means contains value
Shift-F9
while debugging
Moves the cursor to the selected method, variable, class
F12
definition.
Finds the reference to the selected method, variable, class or
Shift-F12
the item under the cursor
Ctrl-} Match curly braces, brackets or compiler directives
Select text between matched braces, brackets or compiler
Ctrl-Shift-}
directives
Text Navigation Shortcut Keys

ShortCut Description
Ctrl-End Moves the cursor to the end of the document
Ctrl-Home Moves the cursor to the start of the document
Displays the Go to Line dialog. If the debugger is running, the
Ctrl-G
dialog also lets you specify addresses or function names to go to
Moves the cursor to the matching brace in the document. If the
Ctrl-] cursor is on an opening brace, this will move to the corresponding
closing brace and vice versa
Ctrl-K, Ctrl-N Moves to the next bookmark in the document
Ctrl-K, Ctrl-P Moves to the previous bookmark
Ctrl-K, Ctrl-I Displays Quick Info, based on the current language
Scrolls text down one line but does not move the cursor. This is
Ctrl-Down
useful for scrolling more text into view without losing your place.
Arrow
Available only in text editors
Scrolls text up one line but does not move the cursor. Available
Ctrl-Up Arrow
only in text editors
Ctrl-Right
Moves the cursor one word to the right
Arrow
Ctrl-Left Arrow Moves the cursor one word to the left
Navigates to the next definition, declaration, or reference of an
item. Available in the object browser and Class View window. Also
Ctrl-Shift-1
available in source editing windows if you have already used the
Edit.GoToReference (Shift-F12) shortcut
Navigates to the previous definition, declaration, or reference of an
Ctrl-Shift-2
item

Text Manipulation Shortcut Keys

ShortCut Description

Shift-Tab Moves current line or selected lines one tab stop to the left

Backspace or
Deletes one character to the left of the cursor
Shift-Backspace
Ctrl-G Go to Particular line
Marks the current line or selected lines of code as a comment,
Ctrl-K, Ctrl-C
using the correct comment syntax for the programming language

Removes the comment syntax from the current line or currently


Ctrl-K, Ctrl-U
selected lines of code
Ctrl-T or Swaps the characters on either side of the cursor. (For example,
Shift-Enter AC|BD becomes AB|CD.) Available only in text editors

Ctrl-K, Ctrl-L Removes all unnamed bookmarks in the current document

Automatically determines logical boundaries for creating regions


Ctrl-M, Ctrl-O in code, such as procedures, and then hides them. This collapses
all such regions in the current document

Alt-Right Arrow Displays statement completion based on the current language or


or autocompletes word if existing text unambiguously identifies a
Ctrl-Spacebar single symbol

Removes horizontal whitespace in the selection or deletes


Ctrl-K, Ctrl-\
whitespace adjacent to the cursor if there is no selection

Applies the indenting and space formatting for the language as


Ctrl-K, Ctrl-F specified on the Formatting pane of the language in the Text
Editor section of the Options dialog to the selected text.

Cuts all selected lines or the current line if nothing has been
Ctrl-L
selected to the clipboard
Deletes all selected lines or the current line if no selection has
Ctrl-Shift-L
been made
Ctrl-Enter Inserts a blank line above the cursor
Ctrl-Shift-Enter Inserts a blank line below the cursor

Shift-Alt-T Moves the line containing the cursor below the next line

Ctrl-J Lists members for statement completion when editing code

Ctrl-U Changes the selected text to lowercase characters


Ctrl-Shift-U Changes the selected text to uppercase characters
Ctrl-Shift- Displays a tooltip that contains information for the current
Spacebar parameter, based on the current language
Removes the outlining information for the currently selected
Ctrl-M, Ctrl-U
region

Ctrl-M, Ctrl-P Removes all outlining information from the entire document

Ctrl-R, Ctrl-P Swaps the anchor and endpoint of the current selection

Toggles all previously marked hidden text sections between


Ctrl-M, Ctrl-L
hidden and display states
Ctrl-K, Ctrl-K Sets or removes a bookmark at the current line
Toggles the currently selected hidden text section or the section
Ctrl-M, Ctrl-M containing the cursor if there is no selection between the hidden
and display states

Ctrl-K, Ctrl-H Sets or removes a shortcut in the tasklist to the current line

Ctrl-R, Ctrl-R Enables or disables word wrap in an editor


Ctrl-R, Ctrl-W Shows or hides spaces and tab marks
Ctrl-Delete Deletes the word to the right of the cursor
Ctrl-Backspace Deletes the word to the left of the cursor
Transposes the two words that follow the cursor. (For example, |
Ctrl-Shift-T
End Sub would be changed to read Sub End|.)

Project Related Shortcut Keys

ShortCut Description
Ctrl-Shift-B Builds the solution
Displays the New File dialog. Note: files created this way are
Ctrl-N not associated with a project. Use Ctrl-Shift-A to add a new
file in a project
Ctrl-Shift-N Displays the New Project dialog
Ctrl-O Displays the Open File dialog
Ctrl-Shift-O Displays the Open Project dialog
Shift-Alt-A Displays the Add Existing Item dialog
Ctrl-Shift-A Displays the Add New Item dialog
Allows you to override base class methods in a derived class
Ctrl-Alt-Insert when an overridable method is highlighted in the Class View
pane
Collapse all the methods, classes, regions in the current code
Ctrl-M-O
behind or class file
Expands all the methods, classes, regions in the current code
Ctrl-M-P or Ctrl-M-L
behind or class file
Ctrl-F Displays the Find dialog
Ctrl-H Displays the Replace dialog
Ctrl-Shift-F Find the reference of selected item into entire solution.
Move from one opened file to another opened file in visual
Ctrl-Tab
studio.
F9 Sets or removes a breakpoint at the current line
Enables or disables the breakpoint on the current line of code.
Ctrl-F9
The line must already have a breakpoint for this to work
F5 Runs the code with invoking the debugger.
Ctrl-F5 Runs the code without invoking the debugger.
Displays the Properties window, which lists the design-time
F4 or Alt-Enter
properties and events for the currently selected item
Displays the Server Explorer window, which allows you to view
and manipulate database servers, event logs, message
Ctrl-Alt-S
queues, web services, and many other operating system
services
Displays the Solution Explorer, which lists the projects and files
Ctrl-Alt-L
in the current solution
Displays the Toolbox, which contains controls and other items
Ctrl-Alt-X
that can be dragged into editor and designer windows
Displays the Immediate window, where you can find the
Ctrl-Alt-I controls or variables values or can do data manipulation during
debugging

1. Adding Namespaces Automatically / Resolve Namespaces.

If you are adding a new class in your code you may need to add the correspondence
namespace. To do it, you may either manually type the Using Namespace or you just right
click on the class name and select Resolve > Namespace. But using Ctrl+. you can
automatically add the namespace in your code.

Lets consider you want to add DataTable in your code, so for that you right click on that class
and select resolve to resolve the namespace.

Fig: Use Right Click To Add Namespaces

But using Ctrl+. you can automatically add the using statement . See the below Image.
Fig : Add namespace using Shortcut key.

2. Generate Method Stubs

You can also generate the methods stubs using the same shortcut key. Like, If you want to
create method which will add to number, you can write like AddTwoNumber() and press
Ctrl+. and Enter to generate the Stub for your methods automatically

Fig : Create Method stubs using Ctrl + .

Fig : Generated Stub for the methods


The most interesting point it will generate the stubs based on the type of argument we are
giving. As shown in below picture for first arguments its generated integer and for second its
generated string.

Fig: Generated stubs based on parameters

3. Implement Interface/ Abstract Class :

Like similar process that we have used for first two example you can implement all the
Interface or Abstract class using the same shortcut.

As for example you have a Class called student which Implement Interface IStudentInfo,
instated of manually implement all the properties or methods for the interface you can
generate the interface stubs automatically.

Fig: Implement Interface


Fig: Implemented stubs for the interface

4. Generate Automatic Class Files

This is related with features 3. If you are trying to implement one Abstract Class or Interface
which is not created, by using this shortcut key you can create the file automatically. You do
not need any manual process to add the file. By using Ctrl+. and Enter a class files with
the same name will be automatically added in App_Code Folder.

Fig: Generate new class/interface using shortcut key


Fig: Automatically Created Files in App_Code

5. Rename Member variables or Classes

By using the same key Ctrl+. you can also rename the same referenced variable at a time
in all over the application.

Fig: Renaming all referenced variables at a time

Manage Visual Studio

Ctrl+S Save current file


Ctrl+Shift+S Save all files
Ctrl+Shift+N Create new project
Ctrl+O Open file
Ctrl+Shift+O Open project
Ctrl+Shift+A Add item to project
Esc Close menu or dialog
Ctrl+P Print
Shift+Alt+Enter Toggle full screen mode
Ctrl+F4 Close current tab
Ctrl+F6/Ctrl+Shift+F
Go to next / go to previous window
6
Ctrl+Tab, then Arrow Press and hold Ctrl+Tab, then using arrow keys gives
keys a small task manager with all open files and views
Ctrl-[/ Ctrl+S Ffind current document in Solution Explorer

Bookmarks
For keystrokes with two keys such as Ctrl+k+k, keep holding the Ctrl key
until releasing the last key.
Ctrl+K+K Toogle bookmark
Ctrl+K+N Goto next bookmark
Ctrl+K+P Goto previous bookmark
Ctrl+Shift+K+N Goto next bookmark in folder
Ctrl+Shift+K+P Goto previous bookmark in folder
Ctrl+K+W Put focus on bookmark window
Esc Leave bookmark window and focus on editor
Ctrl+K+H Toggle code shortcut at current line*
Ctrl+K+L Clear all bookmarks
Ctrl+\+T Show Task List (including code shortcuts)
*if somebody figures out additional shortut keys on how to use code
shortcuts, please edit this page and add.

Code Editor

Find, Replace, and Goto


Ctrl+F Find and replace dialog box
F3/Shift+F3 Find next / find previous
Ctrl+H Display Replace options on the quick tab
Shift+F12 Find all references for selected symbol
Ctrl+Shift+F Find in files
Alt+F3, s Stop current find in files operation
Ctrl+F3/Ctrl+Shift+
Find next / find previous in selected text
F3
Alt+F12 Find symbol
Put cursor in find/command box of the toolbar. Use
Ctrl+D
ctrl+/ in Visual C#
Ctrl+I/Ctrl+Shift+I Incremental search / reverse incremental search
Shift+Alt+F12 Quick find symbol
Ctrl+, Display Navigate-To dialog box
Ctrl+G Goto line number
Ctrl+] Go to matching brace in source file
Shift+Ctrl+Arrow
Jump to next occurrence of highlighted symbol
down
Shift+Ctrl+Arrow
Jump to previous occurrence of highlighted symbol
up
Undo, Redo, Copy, Paste
Ctrl+x, Ctrl+c, Ctrl+V Cut, copy, paste
Ctrl+Shift+V Pastes an item from the Clipboard ring
Ctrl+Z Undo
Ctrl+Y Redo (or Shift+Alt+Backspace, or Ctrl+Shift+Z)

Select Text
Shift+Arrow Keys Extend selection one character/one line
Ctrl+Shift+End/Ctrl+Shift+H Extend selection to end / to beginning of
ome document
Ctrl+Shift+] Extend selection to nexst brace
Extend selection to end / to beginning of
Shift+End/Shift+Home
line
Shift+Page Down/Shift+Page Extends selection down one page / up one
Up page
Ctrl+W Select current word
Esc Cancel Selection
Ctrl+Shift+Page Down/Page Moves cursor and extend selection to the
Up last line / first line in view.
Ctrl+Shift+Arrow Right/Arrow Extend selection one word to the right / one
Left word to the left
Ctrl+A Select All

Coding
Collapse Items

Ctrl+M+M Collapse / un-collapse current preset area (e.g. method)


Ctrl+M+H Collpase / hide current selection
Ctrl+M+O Collapse declaration bodies
Ctrl+M+A Collapse all
Ctrl+M+X Uncollapse all
Ctrl+m, ctrl+T Collapse Html tag

Edit Code
Delete current line or selection of lines to and add to
Ctrl+L
clipboard
Ctrl+Shift+L Delete current line or selection of lines
Ctrl+Delete Delete word to right of cursor
Ctrl+Backspac
Delete word to left of cursor
e
Ctrl+Enter Enter blank line above cursor
Ctrl+Shift+Ent
Enter blank line below cursor
er
Ctrl+Shift+U Make uppercase
Ctrl+U Make lowercase (reverse upercase)
Ctrl+K+C Comment selected text
Ctrl+K+U Uncomment selected text
Remove white space and tabs in selection or around
Ctrl+K+\
current cursor position
Ctrl+K+D Format document to code formatting settings
Ctrl+K+F Format selection to code formatting settings
Ctrl+Shift+Sp
Display parameter required for selected method
ace
Ctrl+Shift+8 Visualize whitespace (or press Ctrl+r, then Ctrl+w)
Ctrl+K+D Format document to code formatting settings
Ctrl+K+F Format selection to code formatting settings
Transpose word to right of cursor; makes b=a out of a=b if
Ctrl+Shift+T
cursor was in front of a
Transpose character left and right of cursor; cursor
Ctrl+T
between ab would make ba
Transpose line: Move line below cursor up and current line
Shift+Alt+T
down.

IntelliSense and Code Helper


Autocomplete word from completion list (or alt+right
Ctrl+Space
arrow)
Ctrl+Shift+Spac
Show parameter info
e
Ctrl+F12 Display symbol declaration
F12 Display symbol definition
Ctrl+J Open IntelliSense completion list

Build and Debug

F6 Build solution (or Ctrl+shift+b)


Ctrl+Alt+F7 Rebuild solution
Ctrl+Break Cancel build process
Ctrl+\+E Show error list
F9 Toggle breakpoint
Ctrl+B Insert new function breakpoint
F5 Start debugging
F11 Debug / step into
F10 Debug / step over
Shift+F11 Debug / step out
Ctrl+F10 Debug / run to cursor
Ctrl+Alt+Q Show Quickwatch window
Ctrl+Shift+F10 Set current statement to be the next executed
Alt+* (on numeric
Show nexst statement
keyboard)
Ctrl+Alt+E Show Exception dialog box
Toggle between disassembly and user code
Ctrl+F11
view
Shift+F5 Stop Debugging
Ctrl+F5 Bypass debugger
Ctrl+Alt+P Show attach to process window
Ctrl+Alt+break Break all executing threads

Tool Windows

Ctrl+/ Put cursor in the find/command box in toolbar


Ctrl+K+B Open code snippet manager window
Alt+F11 Open macro IDE window
Ctrl+K+W Open bookmark window
Ctrl+Alt+K Open call hierarchy window
Ctrl+Shift+C Open class view window
Ctrl+Alt+A Open Command window
Ctrl+Shift+O Open Output window
Ctrl+Shift+E Open Resource view window
Ctrl+Alt+S Open Server explorer window
Ctrl+Shift+L Open Solution explorer window
Shift+Esc Close Find & Replace Window

For HTML Pages

F7 Toggle between Design and Code behind pages


Shift+F7 Toggle between Design and HTML Source
Ctrl+Page Down / Page Up Cycle between design, split and source
Ctrl+Shift+F9 Delete all breakpoints

http://visualstudioshortcuts.com/2013/

You might also like