Skip to content

Instantly share code, notes, and snippets.

@jpoehls
Created March 13, 2012 19:02
Show Gist options
  • Save jpoehls/2030795 to your computer and use it in GitHub Desktop.
Save jpoehls/2030795 to your computer and use it in GitHub Desktop.
Using CTRL+W to close tabs in Visual Studio

In Tools | Options | Keyboard...

  1. Add CTRL+W as a Global shortcut for Window.CloseDocumentWindow
  2. Remove the CTRL+W shortcut for Edit.SelectCurrentWord

The caveat to this is if you are used to using CTRL+W to select the current word. If you do, find another shortcut that works for that.

@domingoladron
Copy link

For those on Resharper, it appears Ctrl+W is used by a couple commands. In order to get Ctrl+W to close a window, you have to clear the Resharper keyboard settings first.

vs-resharper-ctrl-w

@ricardoschwarz
Copy link

thank you

@Nereare
Copy link

Nereare commented Nov 19, 2022

Thank you so much! ❤️

@LaurentBartkowski
Copy link

Thank you !

@niuage
Copy link

niuage commented Mar 3, 2024

Still useful to this day :)

@verdantburrito
Copy link

verdantburrito commented Jun 20, 2025

Here are the steps I used to configure Visual Studio 2022 to use the Ctrl+W keyboard shortcut to close an active text editor tab:

  1. Using the Visual Studio top menu bar, navigate to "Tools > Options > Environment > Keyboard".

  2. Delete any existing keyboard shortcuts that are already bound to Ctrl+W.

    1. In the “Show commands containing” textbox, type “Edit.NextKeyTyped”.
    2. In the "Shortcuts for selected command" dropdown, verify that "Ctrl + W (VC Accelerator Editor)" is selected.
    3. Click the "Remove" button.
    4. In the “Show commands containing” textbox, type “Edit.SelectCurrentWord”.
    5. In the "Shortcuts for selected command" dropdown, verify that "Ctrl + W (Text Editor)" is selected.
    6. Click the "Remove" button.
  3. Create a new Ctrl+W keyboard shortcut that binds to the Window.CloseDocumentWindow command.

    1. In the “Show commands containing” textbox, type “Window.CloseDocumentWindow”.
    2. In the "Shortcuts for selected command" dropdown, verify that "Ctrl + F4 (Global)" is selected.
    3. In the “Use new shortcut in” dropdown, set the value to “Text Editor”.
    4. Click the “Press shortcut keys” textbox, press the Ctrl+W keys on your keyboard simultaneously.
    5. Click the “Assign” button.
  4. Click the “OK” button to save your changes & close the modal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment