In this post, I will list some of
the Visual Studio Tips & Tricks that Every Developer Should Know.
Tip #1 –
USE "PROP + TAB + TAB" to create property
It takes a lot of time to declare
property by typing all words. Instead of typing the whole declaration just type PROP and press TAB + TAB. When we type PROP and press TAB + TAB, we
get a code template for declaring a property then use TAB to move between the
template parameters. This will save time to declare property by typing all words.
Tip #2 –No
need to select entire line to copy or delete
To copy or delete line generally, the user selects an entire line of code in the Visual Studio code editor. But in the visual studio, there is a way by which the user can easily copy or delete line
without selecting. If we want to copy a line then we can simply press CTRL
+ C to copy the line and press CTRL + V to paste the line. If we want to delete
a line, don’t select it first, just press CTRL + X. This will save too much
time to copy-paste or delete the single line.
Tip #3 –
Close all documents except the currently selected one
While working we open multiple
documents. But after working for a long time we found many open documents in
visual studio. When we want to refer any document from open documents, we must
go through the whole list of open documents which takes times. In such a case, we want
to close all documents or all the documents except we are referring.
To close all documents except we are
referring, we can simply right-click the current document tab and then select menu
option Close All But This. Selecting this option closes all
open documents except the document corresponding to the tab.
To close all open documents then
right-click on any open tab and then select menu option Close All
Documents.
Tip #4 –
Use CTRL-K + C to comment code
While
writing code many times, we required to disable or comment a few lines of code
before executing new code. We can do this by pressing CTRL-K + C. To
uncomment code press CTRL-K + U
Tip #5 –
Use CTRL + N to add New Item in the visual studio project
To quickly add a New Item into
a Visual Studio project is to press CTRL + N. This combination opens the
Add New Item dialogue box.
Tip #6 –
USE CTRL
+ Space or Alt
+ RightArrow to AutoComplete statement
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.
Tip #7 – USE CTRL + E + W to word wrap
Many time code line is too long
and to go through the whole code we have to do horizontal scroll. To avoid
horizontal scroll, we can do word wrap. We can do this by using shortcut key CTRL + E + W.
Tip #8 –
USE CTRL
+ K + D to Format whole document
To format whole document code,
we can use shortcut key CTRL + K + D
Tip
#9 – USE CTRL + K + F to Format Selection
To format selected section of
code, we can use shortcut key CTRL + K + F
Tip #10 –
Bookmark shortcut
Bookmarks allow us to mark
places in our code that we want to come back. To use bookmark quickly we can
use below shortcut keys.
- Create/Remove Bookmark - CTRL + K, CTRL + K
- Move to next bookmark - CTRL + K, CTRL + N
- Move to the previous bookmark - CTRL + K, CTRL + P
- Clear all bookmarks - CTRL + K, CTRL + L
Tip #11 –
Remove and sort unnecessary using statements by Organize Using
While creating class we have few
unused using statement at the top of the class. After finishing class creation, we can
remove using statements that are not required by
right-clicking the top of the code file, selecting the menu option Organize Using, and then select Remove and Sort. This action will remove all unused
using statements and sort the remaining using statements.