Where can I find possible rules for vscode key bindings? - visual-studio-code

I've googled for this (perhaps poorly?) and I can only seem to find list of key bindings for vscode. So far I haven't found any list of the rules you can add to key bindings (in the when-part). Right now for example, I want to find out if there's a way to make sure a key binding is only active if I have the version control sidebar up and focused. Kind of like:
filesExplorerFocus, terminalFocus, editorTextFocus and explorerViewletFocus.
Since there is a command for setting the focus to the version control sidebar: workbench.view.scm I've experimentally tried scmFocus but to no luck.
Now this is a specific problem, but I'd really like to save myself some time and just be able to run a few ctrl+f through a document of all possible when-rules.

Vscode when clause commands. I only found it through this issue - so there may be a few other undisclosed when clauses: when clause disclosure issues. I see nothing for when the version control sidebar is active though. Perhaps ask about it at that issues page above.
See also https://stackoverflow.com/a/65584576/836330 and especially https://stackoverflow.com/a/65584576/836330

Related

Is it possible to force Quick Open to take a query from the current selection in the editor?

The current editor I have open contains the name of a file or part of the name of a file that I have in my workspace. I want to search for that file by selecting the text of that name from the editor, and then putting that text in the Quick Open search box. Currently, I need to manually copy and paste the text, but I want to have behaviour similar to the cmd + F search box where the selected text from the editor immediately appears in the search bar when it is opened. Is it possible to configure Quick Open to do this as well? Or maybe there is an extension for this?
At the time of this writing, this is currently not configurable.
If you look in the settings, all the settings that allow enabling or disabling this behaviour contain the word "seed" in them: search.seedOnFocus, search.seedWithNearestWord, editor.find.seedSearchStringFromSelection. From my reading/searching, there is no other setting with the word "seed" in it.
I googled "github vscode issues quickopen seed" and found this GitHub feature-request on the VS Code GitHub repo: Fuzzy quick open should use selected text as a starting point #59957 asking for such behaviour to be the default behaviour. The issue didn't get enough support from other users to get added to their backlog (a feature request needs to get a certain number of thumbs up reactions from users within a certain time period after it is created to get considered for implementation), so that feature-request is now closed.
If you want to get such a configuration option, create a feature-request issue ticket. If you want to increase your feature-request's visibility (and therefore its chance of getting enough user support), share a link to it on various programming platforms such as r/vscode.
I didn't find any extensions that do this by googling "vscode marketplace quick open seed" and looking at the top results, but maybe you'll have better luck with different queries.

Zoom in/out with Ctrl+ / Ctrl- not working in Eclipse

In Eclipse, it seems like all the keyboard shortcuts work, except for those that zoom in/out. (I'm on Windows and using Eclipse Version "Kepler Service Release 2") I have already restored the default keys in my preferences as other StackOverflow posts have advised, but it still doesn't work. Does anyone know why? Thanks!
I'll provide an answer, but you haven't really provided enough information for anyone to be confident that they are fully dealing with your problem.
It would still be useful to know what version of Eclipse you're using.
The first thing to do, is determine exactly what the binding is for the "Zoom In" and "Zoom Out" commands, by looking in the "Keys" section in Preferences. It's easiest to type "zoom" in the filter field to limit the table to those functions. I imagine you've already effectively done this, but it is a prerequisite.
The next thing to do is look for conflicts. There are two ways to look for this. First, check the Eclipse log. It will note if there is a keybinding conflict. Second, in that same "Keys" list, remove "zoom" from the filter (if it was there) and click on the "Binding" header to sort by the key sequence. Then page through the list until you find "Ctrl++" and "Ctrl+-" in the list, which I assume are the bindings you have. What you want to check for is if there is another binding in that list where "Ctrl++" BEGINS the key sequence, and is longer than that. Do the same for "Ctrl+-".
If you still don't find any clues from this, I suppose it's possible there's something else you have installed in Windows that is capturing that key sequence. I don't know how you would check for that.

List of all available commands in VSCode

Where can I find the list of all commands available in VSCode and their description?
I'm only aware of these sources:
In the official docs:
This list which only seems to include a subset of Visual Studio Code commands that you might use with vscode.commands.executeCommand API (why is this only a subset of the full list?)
This other list in the keybindings doc, which also only seems to include a subset of all commands available (I suppose those tied to a default keybinding?)
In the editor itself:
I can see a list of commands when I open the "default keybindings". Many actions are commented out with //, but interestingly I don't think this includes all the commands either (e.g. maximizeOtherEditor isn't listed)
Does VSCode have an official list of commands (commandID's) either in its documentation or in its code base? If not:
What's the closest to it?
What's a good way to navigate the code base to try to find all commands and what they do?
I believe that content of "Preferences: Default Keyboard Shortcuts (JSON)" (command ID workbench.action.openDefaultKeybindingsFile) really shows comprehensive list of all native and extensions-contributed commands VSC knows about at moment when invoked.
This file shows keys from VSC's defaults and extension manifests.
Commands with no suggested defaults are those commented out at the end of file.
Their descriptions (as seen in the Command Palette, Keyboard Shortcuts settings, extension Contributions tab and elsewhere) are supposedly in localization properties and I believe there is currently no way to see them along their respective command IDs in single convenient "localized" list. So for now the only way to read the description of command found in aforementioned JSON is pasting its ID into Keyboard Shortcuts search field. (Would be delighted to be proven wrong.)
In case someone ever fell on this and just wanted a quick-list of VSCode commands to browse through: https://gist.github.com/skfarhat/4e88ef386c93b9dceb98121d9457edbf
If you do, please note the VSCode version and commit. These may well be out of date by the time you read them.

Checking if control/command key is currently pressed in VS Extensions

In my extension, I would like to check in a certain function, if the control (or command) key is currently pressed. How is that possible? I couldn't find any field that exposes this information.
If you read the below article
https://code.visualstudio.com/docs/extensionAPI/patterns-and-principles
It says
Visual Studio Code has a very rich extensibility model and there are many ways to extend the tool. However, we do not provide direct access to the underlying UI DOM to extension writers. With VS Code, we’re continually trying to optimize use of the underlying web technologies to deliver an always available, highly responsive editor and we will continue to tune our use of the DOM as these technologies and our product evolve. To maintain performance and compatibility, we run extensions in their own host process and prevent direct access to the DOM. VS Code also includes a built-in set of UI components for common scenarios such as IntelliSense, so that these experiences are consistent across programming languages and extensions and extension developers do not need to build their own.
We realize that this approach may initially feel restrictive to extension developers. We’re always looking for ways to improve our extensibility model and expand the capabilities available to extensions. We look forward to hearing your feedback and ideas.
This means your extension code doesn't run the in editor window context at all. And you can't hack into the webview as the extension api doesn't provide it. So you need to open a Feature request with VScode team and ask them to expose either the last keyboard event or atleast the status of Shift, Ctrl and alt keys. Currently they just discard it and throw it away (if no editor is open) else they send it to the monaco editor before checking for any shortcut combination
This does not directly answer your question but maybe helps solving your problem:
Your extension could contribute two different commands: For example first command myextension.runTarget (noDebug=true) and myextension.debugTarget (noDebug=false). In addition your extension can contribute keybindings that bind those two commands to different hotkeys, for instance CTRL + F5 and only F5.
Looks like vscode itself does it the same way (screenshot of keybindings view):
This question might be of use. With this approach you could track a key down event and then if the key code is equal to command (91 or 93 on Safari/Chrome, 224 on Firefox) or control. From there, you could put in your functionality if this returns as true, or however you want to structure it

Eclipse Key Preferences; Debugging; Adding A "Watch Expression" Using The Keyboard [duplicate]

This question already has an answer here:
Closed 11 years ago.
Possible Duplicate:
Problem With PHP Eclipse Key Binding
How do I define a custom key binding in eclipse?
I have to admit, for a FREE PRODUCT, Eclipse really delivers. However, sometimes I have to scratch my head about certain missing features...
Eclipse has over ELEVEN HUNDRED different key bindings.
(source: rigel222.com)
I would like to use one of those KeyBindings to add a "Watch" Expression to the expressions window, while debugging.
(source: rigel222.com)
Here is an additional screenshot showing that I already understand the "filter" process. I have set key-bindings for everything I could find pertaining to "Watch", but as you can see it doesn't show up in my right-click menu, and does not function when I use the defined keyboard shortcut.
(source: rigel222.com)
Despite the prevailing opinion that this is "blatant whining", It is also a legitimate problem for me.
Please help.
I just tried it and it works: In the given dialog I entered the word watch as the filter text. The list of key bindings was reduced to three elements. I chose watch and gave a new key binding and it worked.
EDIT:
Please try to unbind the other key bindings that occupy Ctrl+F7 or give Watch another unique key binding.