Problem control tabbing in Visual Studio Code - visual-studio-code

When I press Ctrl Tab the windows cycle through most recently used order.
This is winding me up!
So I read up the solution:
To achieve this in Visual Studio Code, you have to edit keybindings.json. Use the Command Palette with CTRL+SHIFT+P, enter "Preferences: Open Keyboard Shortcuts (JSON)", and hit Enter.
Then add to the end of the file:
[
// ...
{
"key": "ctrl+tab",
"command": "workbench.action.nextEditor"
},
{
"key": "ctrl+shift+tab",
"command": "workbench.action.previousEditor"
}
]
That's all good. But then when I try to edit the file, I get this message 'Cannot edit in read-only mode editor'.
OK... so I'll use another editor. I right click on the tab and there is an option 'Open in other editor...' (or something like that). When I click that, nothing happens.
When I search for solutions on 'Cannot edit in read-only mode editor' I get answers to other problems.
I have searched for a file called keybindings.json - can't find it.
Where am I going wrong?
Thanks.
To be able to control the CTRL Tab action

Open the GUI part of the settings responsible for that - Ctrl+K Ctrl+S (the command is named Preferences: Open Keyboard Shortcuts); from there you can either either change those shortcuts or you can open the JSON file (to do the latter you can press Ctrl+O by default or look for the icon in the right end of the tab bar).
As for the JSON, I think the bindings there are evaluated in order (so if you repeat something, the last thing takes precedence) and if you override a default shortcut through the GUI, it would explicitly write a binding that unbinds the command, i.e. same command, but with a minus in front of it.

Related

VS Code Each time when I select another file and start to type, I will type in the side bar, not on a page. How to fix it? [duplicate]

I realize that Microsoft had some sort of reason for adding the new "Find" tool in the folder EXPLORER section of VSC.. but... I'm a creature of habit. When I click on a file and then press Ctrl+F, I immediately start typing the value I'm looking for. The results used to look like this in the file editor pane...
But with my last update, when I click on the file in the EXPLORER and press Ctrl+F, I am now getting this NEW small tool in the EXPLORER pane, and the cursor goes THERE. I type away and nothing happens in the file editor until I swear a few near-curse-words and have to click over in the file editor and then press Ctrl+F again and start all over to type the search string. It's bugging me because its old habit.
How can I go back to the old way of how it worked? Is there a simple configuration buried somewhere I can change?
Thanks.
I don't say see a setting to set the old filter-search method as the default in the Explorer. You can disable the list.find command on which the new find widget in the Explorer depends in your keybindings.json which has the effect you want:
{
"key": "ctrl+f",
"command": "-list.find",
// "when": "listFocus && listSupportsFind"
}
Now Ctrl+F with focus in the Explorer will open the editor Find Widget with focus.
But you lose the ability to filter other lists with the Ctrl+F, such as TreeViews (see https://stackoverflow.com/a/73039598/836330 forexample).
The better solution, IMO, is to set up a macro which works when you have explorerFocus and use the Ctrl+F keybinding. You will need a macro extension, like multi-command. Use this keybinding in your keybindings.json:
{
"key": "ctrl+f",
"command": "extension.multiCommand.execute",
"args": {
"sequence": [
"workbench.action.focusActiveEditorGroup",
"actions.find",
],
"when": "explorerFocus"
},
}
which will switch focus to your current editor and then open the Find Widget therein.
I will provide three steps to achieve this without editing keybindings.json
Step 1: Open keyboard shortcuts
Step 2: Find list.find using the search bar.
Step 3: Change key-binding to f3. If there are multiple bindings f3 and ctrl+f like it was for me, remove ctrl+f key-binding.
Done.
You can open keyboard shortcuts by:
ctrl + k ctrl + s
Open palette ctrl + shift + p, type open keyboard shortcuts.

How do I shut off the new Explorer Ctrl+F Find tool in VSC?

I realize that Microsoft had some sort of reason for adding the new "Find" tool in the folder EXPLORER section of VSC.. but... I'm a creature of habit. When I click on a file and then press Ctrl+F, I immediately start typing the value I'm looking for. The results used to look like this in the file editor pane...
But with my last update, when I click on the file in the EXPLORER and press Ctrl+F, I am now getting this NEW small tool in the EXPLORER pane, and the cursor goes THERE. I type away and nothing happens in the file editor until I swear a few near-curse-words and have to click over in the file editor and then press Ctrl+F again and start all over to type the search string. It's bugging me because its old habit.
How can I go back to the old way of how it worked? Is there a simple configuration buried somewhere I can change?
Thanks.
I don't say see a setting to set the old filter-search method as the default in the Explorer. You can disable the list.find command on which the new find widget in the Explorer depends in your keybindings.json which has the effect you want:
{
"key": "ctrl+f",
"command": "-list.find",
// "when": "listFocus && listSupportsFind"
}
Now Ctrl+F with focus in the Explorer will open the editor Find Widget with focus.
But you lose the ability to filter other lists with the Ctrl+F, such as TreeViews (see https://stackoverflow.com/a/73039598/836330 forexample).
The better solution, IMO, is to set up a macro which works when you have explorerFocus and use the Ctrl+F keybinding. You will need a macro extension, like multi-command. Use this keybinding in your keybindings.json:
{
"key": "ctrl+f",
"command": "extension.multiCommand.execute",
"args": {
"sequence": [
"workbench.action.focusActiveEditorGroup",
"actions.find",
],
"when": "explorerFocus"
},
}
which will switch focus to your current editor and then open the Find Widget therein.
I will provide three steps to achieve this without editing keybindings.json
Step 1: Open keyboard shortcuts
Step 2: Find list.find using the search bar.
Step 3: Change key-binding to f3. If there are multiple bindings f3 and ctrl+f like it was for me, remove ctrl+f key-binding.
Done.
You can open keyboard shortcuts by:
ctrl + k ctrl + s
Open palette ctrl + shift + p, type open keyboard shortcuts.

What does the Ctrl+Shift+D shorcut do in VS Code on Windows?

From time to time I accidentally hit Ctrl+Shift+D instead of Ctrl+D to duplicate selection (I guess a bad piece of muscle memory from those four weeks when I used Atom). This shortcut removes the contents of the editor and it takes some 4 Undo's to undo it. I can't seem to unbind this shortcut because I cannot find it in the user shorcut preferences. There is a default binding (below) but it seems like something else and overriding it in user shortcuts doesn't change anything.
{ "key": "ctrl+shift+d", "command": "workbench.view.debug",
"when": "viewContainer.workbench.view.debug.enabled" },
I was going to open an issue but Github directed me to SO instead, sorry.
Ctrl+Shift+D in vscode opens Run and Debug View.
Can be remapped using Keyboard shortcuts settings Ctrl+K Ctrl+s
Or you can Remove keybinding

Is there a VS Code shortcut to edit the current global "settings.json" file

I frequently have to edit my global settings.json, but not frequently enough to be able to use the open recent menu in VS Code.
Is there a key binding or single button I can press that opens my current settings.json in the current VS Code window? It's irritating to have to keep navigating to /Users/ME/Library/Application\ Support/Code/User/settings.json every time.
Not by default but, if you open up File | Preferences | Keyboard Shortcuts and search for JSON, you'll find there's a Preferences: Open Settings (JSON) item that you can assign a shortcut to.
I've set mine to Alt, to make it similar to Ctrl,, the workbench setting editor.
You can, of course, also store this in your global keybindings.json:
{
"key": "alt+,",
"command": "workbench.action.openSettingsJson"
}

How can I change keyboard shortcut bindings in Visual Studio Code?

Using Visual Studio Code what is the procedure to:
Remap a built in command's keyboard shortcut. For example, say, Open File (default is Ctrl+O, it's unlikely that anyone would actually change this, but the same process should probably apply for any built in shortcut).
Remap an extension command's keyboard shortcut, say the Bookmark extension's toggle-bookmark (default Ctrl+Alt+K)
IN 2015, this involved editing configuration JSON files, but I don't know which one, or how. In 2021 there's a new UI, how do I find it?
Click File -> Preferences -> Keyboard shortcuts. Use the tab that opens up to edit and find available key bindings and assign them.
Historical Note: In very early versions of visual studio code, you would Click File -> Preferences -> Keyboard shortcuts and you would get JSON like this keybindings.json:
// Place your key bindings in this file to overwrite the defaults
[
{ "key": "ctrl+o", "command": "workbench.action.files.openFile" },
{ "key": "ctrl+alt+k", "command": "bookmarks.toggle",
"when": "editorTextFocus" }
]
But now in 2021 versions, there is a proper GUI, which is great because the json editing method was error prone and hard to discover.
The json editor feature has been moved to a new icon:
If you want to change the advance settings of keyboard shortcut such as when then you can follow these steps:
Update:(Thanks #phdoerfler for pointing it out that icon has changed)
File->Preferences->Keyboard Shortcuts
Click on icon on top right corner that says "Open Keyboard Shortcuts(JSON)" to open JSON version and place the keybinding.
You can find this in Documentation here.
The way to open the JSON file changed yet again in a recent version.
You need to click the middle of the three buttons in the tab bar.
You only need to do that if the change you need isn't possible on the normal settings screen.
On Windows:
go to File -> Preferences -> Keyboard shortcuts,
or press Ctrl+K, then Ctrl+S,
or edit %UserProfile%\AppData\Roaming\Code\User\keybindings.json file
On Mac:
go to Code -> Preferences -> Keyboard shortcuts,
or press Cmd+K, then Cmd+S
Keep in mind you can type things like shift ctrl c in the Search input in Keyboard Shortcuts panel to find commands by their keybindings.
Here you can find documentation which among other stuff contains also information about what When conditions you can use.
The latest version of Visual Studio Code 1.11.0 provides a rich and easy keyboard shortcuts editing experience using a new Keyboard Shortcuts editor. Read more here on their website.
I will not repeat others answers! And if like me! You get to install a mapping extension!
My prefered is Visual studio keys map
And the question would have been how you select it! How you change it ! Can we install multiples! And select between them!
First here some useful links about key binding and shortcuts
https://code.visualstudio.com/docs/getstarted/keybindings
https://code.visualstudio.com/docs/getstarted/tips-and-tricks
And before any, know that you can get to the keymaps extension by using the bottom left settings button for settings context menu! As in the picture bellow:
or through file>Preferences>keymap
Then you have to install one of the keymaps
The thing to know is that it will take place and make the changes right away!
What if you install another?
The new one take over! Or some mix! I couldn't tell!
And you may have problems!
How you change from one to another?
Remove the old ! remove the new one! And install it again! That's the way that i found it works! Disabling and reenabling didn't work!
And better always let only one installed at a time!
Unfortunitly as by Now 2020-05-08 no options to select between keys mapping exist!
Undo a keymap
Just remove! You may need to restart the editor!
Restart the editor
Also note that if you uninstalled all and reinstalled the one you want! And changes didn't take place! Close the editor and reopen it! That's help!
I hope that's help and may be save you some searching time!
And sure in the future we will have better handling! As vscode is just keeping getting more awesome and awesome! So an option to select and better handling will is expected to be added! And we will wait for it!
FYI on mac the keybindings.json file sits there:
/Users/your_user_name/Library/Application Support/Code/User/keybindings.json
ctrl + shift + p
Type open keyboard shortcut in the search bar
It opens keyboard Shortcuts. Here you can customize shortcuts.
(For extra info follow from 4th point)
There at the top right corner click on open keyboard shortcuts (JSON) (Refer to the image)
There you can modify the key, command, and when. That is also cool.
I tried
{
"key": "ctrl+a",
"command": "workbench.action.terminal.selectAll",
"when": "terminalFocus && !isMac"
}
by this now I can select all in vscode terminal
On Windows: Ctrl + K, then S
On Mac: ⌘ + K then ⌘ + S
This opens Keyboard Shortcuts Editor. It's searchable/filterable by either shortcut name or the key combination itself (example: type "ctrl" to see all bindings to the CTRL key.)
Image:
vscode search keyword shortcuts panel
Open Key Shortcuts from Preferences -> Keyboard Shortcuts
Search for the action in search field
Right click on one of the results and select "Show same keybindings"
Delete the conflicting key binding!