Reputation: 1281
I changed the shortcut to close a window to Ctrl+W and to close all windows to Ctrl+Shift+W. Close all windows works fine, but Ctrl+W selects the word currently under the cursor but does not close the window.
When I right-click a tab it say Ctrl+W is the shortcut to close it (And also Ctrl+S to save and Ctrl+Shift+W to close all). Why is only the close window shortcut not working?
Upvotes: 40
Views: 17363
Reputation: 5264
2021: For Visual Studio 2019:
See: https://gist.github.com/jpoehls/2030795#gistcomment-2335647
In my case, I had two existing assignments that I had to remove. Thereafter, I could use the hotkey.
Upvotes: 1
Reputation: 61
For Visual Studio 2022, make sure you also remove Ctrl+W
from selectCurrentWord
command.
Upvotes: 6
Reputation: 191
In my case, the tabs were not closing because I am using Vim extension. I had to add the following lines to Vim settings:
"vim.handleKeys": {
"<C-w>": false
}
Just press Ctrl + , or Command + , for Mac users, search for Vim and go into Edit in settings.json as the following picture shows:
Upvotes: 0
Reputation: 515
In Visual Studio 2019 it is Ctrl-F4 by default to CloseDocumentWindow. The action is Window.CloseDocumentWindow. I know this is old but the accepted answer has you change the short-cut key instead. I would rather use the default option.
Tools -> Options -> Environment -> Keyboard
If you're ever unsure go to the path above and you will see the image above then you can click inside the box "Press shortcut key" at the bottom of the form and type the short cut key you're interested in and it will tell you if it is used and what it is currently used for.
You can also reference the docs
Upvotes: 4
Reputation: 1961
For those using linux with VSCode v1.56.2,
File
--> Preferences
--> Keyboard Shortcuts
.
Search for View:Close Editor
and as mentioned above, remove any keybinding that has the keybinding you want.
Upvotes: -2
Reputation: 1
In my VS Pro 2019, on Tools / Options / Environment / Keyboard, the first line offers using a premade keyboard mapping scheme, with a drop-down option for VSCode keyborad mapping theme.
I picked it and it seems to have adopted the keyboard shortcuts I was used to from working on VSCode, Ctrl+W included.
Upvotes: -1
Reputation: 12619
I am using Visual Studio 2017
& Visual Studio 2019
and tried the answer from @TobiMcNamobi but it didn't work for me. After few such tries I got it work with below steps.
You should add it as Global
shourtcut otherwise it will not work for Designer
views.
Global
shortcut for Window.CloseDocumentWindow
Edit.SelectCurrentWord
Upvotes: 33
Reputation: 4813
In Visual Studio (VS 2015 in my case but it's similar down to VS 2010 at least) keyboard shortcuts may have a different meaning depending on the context in which they are executed.
Click Tools / Options / Environment / Keyboard to look up or define shortcuts (you already did that probably). What I called "context" is selected in the combobox labelled "Use new shortcut in:". Most likely you defined the shortcut in "Global" but you want it to work in "Text Editor". In the latter Ctrl+W selects the current word.
Redefine Ctrl+W for "Text Editor" and you should be fine.
Upvotes: 50