Follow us on X (Twitter)  Like us on Facebook  Connect with us on LinkedIn  Subscribe to our YouTube Channel  Subscribe to our WhatsApp Group

You might know that Ctrl + W is a shortcut key for many browsers like Internet Explorer, Firefox, Chrome etc. to close the tab bar items. If you have tabs in the open tab bar and want to close the currently open tab, you can use Ctrl + W shortcut key instead of clicking the close button.

 

In Visual Studio, you might want to do the same. Suppose you have a no. of documents open in your tab and you want to close some of them with a shortcut instead of clicking one by one. How can you do that? Read the post to configure your Visual Studio IDE to assign a shortcut for it.

 

 

Let us again describe here what we want to achieve by this post. Suppose we have a no. of open documents inside Visual Studio, you will see all of them in the tab bar as shown below:

 

image

 

Now sometime it is very difficult to close them one by one by clicking the close button. Ever imagined of a way to use a shortcut to handle it just like we do for the internet browsers? Let me tell you that, there are no shortcut assigned for this. So, let's create our own shortcut key for that.

 

To do this open the Options page from the Tools menu as shown below:

 

image

 

In the options dialog expand the "Environment" tree node from the left panel. There you will find a link called "Keyboard". Click that to open up the Keyboard settings page at the right side. There you will see a input box called "Show commands containing". This textbox searches for the input command in the list just below it.

 

Have a look into the following screenshot:

 

image

 

In the input box type "File.Close" and you will see the command filtered in the list. This command executes instruction to the Visual Studio IDE to close the currently open document. Select the command from the list.

 

Now, the 2nd step is to select the proper location to store a shortcut key for it. Select "Global" as the "Use new shortcut in" dropdown. This will make sure that your shortcut for the command will store in the global settings and will be applicable to any instance of the Visual Studio IDE all over the time.

 

image

 

As the 3rd step, click on the textbox "Press shortcut keys" and enter your desired shortcut key by pressing the respective keyboard keys. In our case, we will use "Ctrl + W". Press "Ctrl" and "W" to enter the key combination in the box.

 

image

 

As shown above once you entered the shortcut key, click "Assign". This will store the key combination for the selected command and you will see the following changes in the dialog:

 

image

 

 

Click "OK" in the dialog box to continue. Now you will be able to close the open document file just by pressing "Ctrl + W" key combination.

 

Hope you enjoyed reading this post. This small tip will help you to quickly close the open documents. Hence, happy coding and enjoy your daily experiences with Visual Studio IDE.

 

Have a question? Or, a comment? Let's Discuss it below...

Thank you for visiting our website!

We value your engagement and would love to hear your thoughts. Don't forget to leave a comment below to share your feedback, opinions, or questions.

We believe in fostering an interactive and inclusive community, and your comments play a crucial role in creating that environment.