Prevent cutting or copying blank lines in Visual Studio

I hope you know that we are not required to select a line to cut or copy it in Visual Studio, you can just keep the caret in a line and press Ctrl + C or Ctrl + X and the text in the line will be copied to your clipboard and you can insert this line anywhere in your code by pressing Ctrl + V.

It will also copy a blank line, but people use Ctrl + X command to delete blank lines and some may find this as an issue as they didn’t intend to copy the blank line and also it will clear the previously copied item in the clipboard.

It is surprising as usual to find that Visual Studio team has thought out this and provided a setting which prevents the copying of blank lines, and Cut command will just delete the blank lines.

I found this when I recently bumped into the setting in Visual Studio, in Text Editor > All Languages called "Apply Cut or Copy commands to blank lines when there is no selection".


Bookmark / Share

Visual Studio 2010 Extension for collapsing solution explorer items

I have recently realised how folks get significantly uncomfortable and could also loose little amount of productivity speed when navigating Solution Explorer which is in a state of mess due to randomly expanded and collapsed Solution Explorer items, it surely causes at least a tiny amount of lack of clarity.

The basic TreeView control or Tree control is a common windows control found in many places in Windows OS, including Windows Explorer. The same is found in Visual Studio’s Solution Explorer, for those who are not aware; this control supports some keyboard shortcuts, I mean whether you are in Windows Explorer or Visual Studio Solution Explorer you can select a node’s parent and use these shortcuts.

+ (plus) --> Expand

- (minus) --> Collapse

* (asterick) --> If you would like to expand recursively a particular item's child items

But there is no shortcut to collapse recursively.

Collapse Selection in Solution Explorer extension is available for Visual Studio 2010 that adds an icon to the Solution Explorer(shown below), clicking which recursively collapses the child items. You can press Ctrl + Alt + Num(-) - numeric keypad’s '-' to use it. This extension is better than the functionality in “PowerCommand for Visual Studio 2010” extension, as explained in the above link.


Bookmark / Share

Have you tried AutoHotkey tool ?

AutoHotkey is a great FREE and open-source tool you can use to create hotkeys and assign them to commands that you can execute on your system. You are asked to create a script file with commands and then open it in the AutoHotkey program to use it. Commands are executed based on the hotkeys assigned to them in the script.

In the script, you can specify simple commands like the one shown below.

#n::Run Notepad

The above command launches Notepad.

# stands for Windows key, ^ for Control key, ! for Alt and + for shift

You can find more commands and general usage info about AutoHotkey in the tutorial page here.

Bookmark / Share

Visual Studio Wallpapers to decorate your desktop!

I was doing a search for visual studio logo to use in a presentation and I stumbled upon a site called, and found some great wallpapers built by the community and thought of sharing with you. You too can create some and submit...


(Click to go to the site)


Find more on the website..

Bookmark / Share

Try, it’s cool

Whenever someone explains some issue they are facing by sending some snippets of code which contains HTML with Javascript or CSS. I use this cool tool called and paste the code they send me in the relevant boxes for HTML, Javascript & CSS in the site and work on the issue.

I do this even if I have the full file set of code in which the issue is present in one part of the code set, this helps much in issue isolation.

So checkout!

Bookmark / Share

A new feature in ASP.NET 4: Shorthand syntax for Html Encoding

So far if we need to HTML encode content that we throw out to the response stream we will use Server.HtmlEncode() method as below.

<%= Server.HtmlEncode(“Content”) %>

Now in ASP.NET 4 we have a new code syntax, which comes handy whenever you want to emit content with HTML encoding, the new syntax is <%: … %> the “=” character is replaced in this new syntax by the “:” character, as shown below.

<%: “Content” %>
Bookmark / Share

A little less cared ASP.NET’s NestedMasterPage

I have seen developers using user controls which will show and hide sections of site content based on the state of the web site. This is fine for some extent, you know when it becomes bad ? It becomes bad when only user controls are used even for site layout related stuff.

ASP.NET’s NestedMasterPage is a great thing, that, I should admit, I myself started using only recently earlier I was using other ways to display a set of pages in different layout in a website. NestedMasterPage is a master page which is based on another master page, you can have as many levels of nesting as you wish, as far as you don’t confuse yourself.

You create a NestedMasterPage based on which other normal ASP.NET pages will be created. You can have a Main master page in which a website’s most common UI elements are present and create NestedMasterPages for different areas of a site like subsections of a site like web interface for post Member login, etc.

Below is a simple depiction of what could be done with a NestedMasterPage in ASP.NET web forms.


Now, below images will give you some idea on how the layout of a site can be less messy if we use NestedMasterPages.

(click to enlarge)


(click to enlarge)


Hope it’s understandable.

Bookmark / Share

Do you know Notepad’s .LOG feature?

Thought of posting a simple feature of notepad that might be useful for many who log things in a file for various purposes, mostly this can be used for simple things that needs to be logged.

In Notepad, type ".LOG" (case sensitive) in first line of the file and save it, now close and reopen the file, current date and time will be inserted in the last line and you can type information and save.


Bookmark / Share

Code Snippets in Visual Studio

This post gives introduces code snippets in Visual Studio, how you can use them and helps you find out the list of built-in code snippets for each language easily. Code snippets in Visual Studio are useful in reducing typing effort required to input code. Code Snippets help in several ways to simplify your work if you can remember to use them instead of typing the actual code. Code Snippets are present in Visual Studio from ver 2005.

To use code snippets, instead of typing the code you will type a shortcut, which actually is a word and press Tab key to insert the actual code to which the shortcut is linked with.

For example, to enter the below code..

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


You can type "for" and then press Tab, you will then get the code inserted into the code window as shown below..



Now you can see that “i” is highlighted, this means you can type a name for the loop variable, once you renamed it, you can press Tab to select “length” and rename it or specify what should be there, like, list.Count, etc. Once done, press enter to place the cursor inside the for loop braces.

As you can see, whenever you need to write a for loop you can just use this code snippet and save time, there are many code snippets like this which you can use.

Also, you can right click in the code editor and select Insert Snippet...(Ctrl+K, X) and choose the snippet you need from the list. You can also select lines of code and right click and select Surround With...(Ctrl+K, S) option to put the selected code into the snippet that you will insert, like, inside a try..catch block.

Code snippets are actually customizable as like most Visual Studio features. A code snippet is loaded from a “.snippet” file and the below image shows the location of the built-in C# code snippets. You can find snippets for VB & other languages in the language specific folder.


(C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC#\Snippets\1033\Visual C#)

I will write a future post on how to create your own code snippet for frequently entered common code patterns in your project and how to distribute them within your team so that everyone can use them.

Bookmark / Share

New ASP.NET project gives a great webapp template in Visual Studio 2010

(This post is part of Visual Studio 2010 series)

When you create a new ASP.NET web application in Visual Studio 2010, you are getting a project which has a good set of features built into it for you to get started quickly. In previous versions of Visual Studio, when you create a new ASP.Net project, you just get one .aspx page with a web.config file.



(Visual Studio 2010’s solution explorer showing the contents of a just created Web Application project)

Visual Studio 2010’s new project template has the following..

  • Master page – with menu, login view control, etc., has good div based layout with nicely used css styles. Along with two files based on master page(Default.aspx & About.aspx).
  • Stylesheet - with styles for most elements your web pages will be designed with, that you can customize as you wish
  • Forms authentication enabled – provides you with .aspx pages which implements forms authentication, like, login, register new user and change password, with necessary configurations in web.config
  • Web.config file with Debug and Release versions, including sample Web.config transformations that you most probably need
  • Web.config readily configured for ASP.NET Membership, Roles & Profiles
  • jQuery library .js files included with three versions of .js files – one with Visual Studio intellisense support, a normal one and a minified one-which is used for production.


This new project template would help beginners and people who are yet to get good overview on how a typical ASP.NET web site would be written.

Bookmark / Share