In Tools | Options | Keyboard...
- Add
CTRL+W
as a Global shortcut forWindow.CloseDocumentWindow
- Remove the
CTRL+W
shortcut forEdit.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.
Edit: SOLVED!
I have tried this so many times, but have not achieved success. Until seeing the comments from 2017 suggesting it still works, I assumed Visual Studio had made some change breaks the functionality.
For some reason, after removing the shortcut to Edit.SelectCurrentWord, and even a different key combination to it, pressing CTRL+W doesn't close the window. It still selects the current word. I have also tried assigning CTRL+W to File.Close, as some other sources suggest, but to no avail. Window.CloseDocumentWindow does function correctly with the default CTRL+F4, as well as with other unassigned key combinations (e.g. CTRL+ALT+SHIFT+])
Does anybody know what could possibly be wrong? Thank you!
Solution:
It was also assigned to other conflicting things (other than Edit.SelectCurrentWord). This seems obvious now, but I assumed a "Global" shortcut would override any other associations. Instead it seems that the global applies in any circumstance that a more specific shortcut isn't defined. (Which does make sense.)
So for anybody else experiencing this problem:
Now, the global association made to CTRL+W shall work.