How to trigger documentation popup in vscode - visual-studio-code

How to trigger a popup with documentation for identifier under the cursor?
Normally it appears when hovering the identifier using the mouse pointer:
I would like to achieve this effect using a command or keyboard shortcut.
The only related commands I found are: trigger completion (which doesn't show the function doc) and trigger parameters hint (which only works when the cursor is inside function call - parameters list).

This is the editor.action.showHover command. It is bound to cmdk cmdi by default.
Note: Shortcut works by holding down the cmd [ctrl in windows], then while holding press k then i
You can change the keyboard shortcut with a keybinding such as:
{
"key": "cmd+k ctrl+space",
"command": "editor.action.showHover",
"when": "editorTextFocus"
}

The default shortcut for Trigger Parameter Hints is Ctrl+Shift+Space

You also have, with VSCode 1.40 (Oct. 2019):
Definition Preview Hover from the keyboard
There is a new command Show Definition Preview Hover for better accessibility of the definition preview hover widget, which can be triggered by hovering a symbol with the mouse and pressing a modifier key dependent on the platform and configuration.
Previously, only the command Show Hover was provided, which is equivalent to hovering the mouse cursor over a symbol.
Now, with Show Definition Preview Hover, the detailed hover information can be shown via the keyboard.

To make this more graphic, check these steps:

In Visual Studio 2019 for Mac, I couldn't find anything about "hover" in the Key Bindings setting. The relevant command seems to be called "Show quick info" and is bound by default to Cmd + F1.
I know this question is about VSCode but I could only find this question when trying to search for an answer. Therefore I would also like to leave the information here in case somebody finds it useful.

There are multiple ways to trigger the documentation popup:
First: Using shortcut ctrl + space
Second: Using vscode extension:
Here is the documentation:

Each answer here demonstrates a different function. Below is a consolidation of every type of helpful popup, the context in which they come up and all the ways I know to trigger them.
These assume default settings.
Function: Display documentation
Shortcut: Ctrlk Ctrli
Scope: Works over named elements - variable and function names (does nothing over literals).
Can display function documentation:
or variable or even property information:
This is the same pop-up you get when you hover over the element briefly.
Function: Display parameter hints.
Shortcut: CtrlShiftSpace
Scope: Works inside a function call.
The cursor must be inside the parenthesis that contain the passed arguments. Does nothing outside that scope.
Can also be triggered by typing a comma, as if passing another argument.
Up/Down arrows can be used to cycle through overloaded definitions (instead of moving the cursor up and down the document).
Function: Display the code completion menu
Shortcut: CtrlSpace
Scope: Anywhere. Will adapt to the context. In strings will display words only. In code will offer symbol hints - function names, variable names within the current scope, known properties, etc.
Is case insensitive.
Matches all contained characters - they do not have to be consecutive (see image above).
Tab or Enter accepts the currently selected suggestion.
Symbol hints can be triggered by just typing letters. Inside strings you must use the keyboard shortcut.

Related

Powershell 7.3.0 Tab completion not working

I've recently upgraded PowerShell to version 7.3.0 version and now, when I type a command, I see its suggestions like when I'm typing pip it adds list like in this image. Or when I type start of the command it suggests its full name.
The problem is that when I press Tab it doesn't complete the command, instead it just starts listing current directories, i.e. here is an image after pressing Tab once.
Also even when I start typing the full name of the command like pip li it still shows the ending, but when pressing Tab it just does nothing.
I expected this to complete the current command with the suggestion after Tab is pressed.
I've tried to google this problem but haven't found the exact same case I have with 7.3.0 version.
Just press -> (right arrow) key
If you want to change key bindings:
source: https://devblogs.microsoft.com/powershell/announcing-psreadline-2-1-with-predictive-intellisense/
Key Bindings for Predictions
Key bindings control cursor movement and additional features within the prediction. To support users running Predictive IntelliSense on multiple platforms, key bindings are user-settable from the command line or your profile script.
PSReadLine contains functions to navigate and accept predictions. As an example, to accept a displayed prediction, PSReadLine contains functions:
AcceptSuggestion – Accept the current inline suggestion
AcceptNextSuggestionWord – Accept the next word of the inline suggestion
AcceptSuggestion is built within ForwardChar, which by default is bound to RightArrow. Pressing RightArrow accepts an inline suggestion when the cursor is at the end of the current line.
AcceptNextSuggestionWord is built within the function ForwardWord, which can be bound with Ctrl+f by Set-PSReadLineKeyHandler -Chord "Ctrl+f" -Function ForwardWord. Pressing Ctrl+f accepts the next word of an inline suggestion when the cursor is at the end of current editing line.
As a user, you can bound other keys to AcceptSuggestion and AcceptNextSuggestionWord for similar functionalities. Search for ForwardCharAndAcceptNextSuggestionWord in SamplePSReadLineProfile.ps1 for an example to make RightArrow accept the next word from inline suggestion, instead of the whole suggestion line.
List of additional suggested key bindings defined in PSReadLine SamplePSReadLineProfile.ps1

Make a specific VSCode output view visible?

In the VSCode "panel" there are the tabs "problems", "output", "terminal", debug console". Within the output tab is a drop-down menu containing many different output views, such as "Tasks", "Extensions", "Git", etc.
I would like to have it make a specific output view visible automatically. For example, when starting a debug session, VSCode may have made the "Adapter Output" view visible, but I'd like to hit a hotkey (or fully automate it) to switch to a different output view.
I'm not certain if this can be done through a task or if it would require an extension, but I cannot find any information on it. Presumably it's possible, though, since VSCode obviously switches panel tabs automatically, and it will make different output views visible depending on the situation.
In this specific case, I'm using the cortex-debug add-on, and SWO text output is sent to an output view during debug sessions. I'm interested in having that output view made visible automatically when I launch the debug session.
Thanks!
Changing the Output View
"So obviously, as you have already mentioned, the way most people switch output views is by opening the drop-down reading the list, until they see the output-view they are looking for, which they then select... Which is slow. Drop downs are counter-productive when attempting to Navigate your Editor quickly. For me, it is easy to see why you want an alternate method for selecting the output's view."
There's a Better way.
For starters your going to need to access, and create custom keybindings. The command hooks are their for you to switch to the outputs you want, but they haven't been added to the default commands yet, and they may not be added ever (which is why you are going to add them now). Below is a simple guide explaining how to make a keybinding in VSCode:
Note: This is part 1 of 2 parts
PART #1
Creating Keybindings
Each Keybinding Has 3 Essential Properties:
key: this describes the pressed keys.
command: Contains the actual command that is to be executed, a limited list can be found in the VSCode Docs. (Click here to see them)
when: This is the when-context, which sets conditional True or False clause which is evaluated upon execution of the command you wrote.
as a reference, this is one of my keybindings I use for disabling ESLint on specific lines where I intentionally break Es-Lints rules.
// ~/.config/Code/User/keybindings.json
// This allows me to pin and unpin editor tabs using the same exact keys
// It is the when clause that makes these keybindings I created possible.
// ctrl+shift+space (& then) ctrl+shift+space (again)
{
"key": "ctrl+shift+space ctrl+shift+space",
"command": "workbench.action.pinEditor",
"when": "!activeEditorIsPinned"
},
{
"key": "ctrl+shift+space ctrl+shift+space",
"command": "workbench.action.unpinEditor",
"when": "activeEditorIsPinned"
},
Note: Sometimes their is an args property.
Moving on...
Part #2
Creating the Keybinding that is Specific to what you want:
Okay so now that you know how, I will give you the clauses, which are slightly hard to locate at first (or at-least they were for me), but once I found them I now always know where to look:
If you drop open the Command-Palette via the [F1] KEY and type "Keyboard Shortcuts", two options for "Keyboard Shortcuts" will popup:
One of the options will read: "Default Keyboard Shortcuts"
The other will simply read: "Keyboard Shortcuts"
They will both open keybindings.json files, but they are two different files in two different locations. The DEFAULT keybindings.json file will be Read-only (its not writable), it is the default keybindings that come with VS-Code. The Default one is important because it contains the long list of commands that can be used when creating keybindings. It is currently the best resource for Keybinding commands anywhere.
The regular keybindings.json file will be empty if you never used it, and this is where you can define your keybindings. To start while focused on the keybindings.json file, hit [Ctrl+k] [Ctrl+k] (twice back to back). An input will pop up where you can define a keybinding, by pressing any keys you want. Once you have defined your keybinding press enter and it will create a preformatted keybinding block for you, it will pre-type the Key Combination you designed as well. In the block enter the When clause you want (you have to figure out when this keybinding is going to be executed, you may or may not be able to leave it blank. A blank "when": "" clause is like telling the editor...
_"This keybinding is to be executed at anytime I use the Key Combination that is associated with it via the key-property".
Last but not least the good stuff:
The output commands:
git.showOutput
notebook.diff.showOutputs
npm-script.showOutput
eslint.showOutputChannel
testing.openOutputPeek
testing.showMostRecentOutput
There may be more, but that's what I was able to find in the Default Keybindings.json file.

How to make IntelliSense show the parameters of a function in VSCode?

How can I make Intellisense show up the function parameters once the parentheses are written down? It shows only if I just type them like in the tutorial example, but not once they are already written and I set the cursor with the mouse inside.
I think you want the Trigger Parameter Hints command. If you type it in the command palette it will show your current short-cut (mine is Ctrl+Shift+Space).

Eclipse - multiline comment with asterisks doesn't work

I'm not able to use ani shortcuts for using comments with asterisk. Every key combination doesn't work. I tried with CTRL+/, CTRL+SHIFT+/, CTRL+C; all of these have the same output, i.e. a simple comment with // on every line. Other shortcuts like CTRL+\, CTRL+SHIFT+\ or CTRL+SHIFT+F doesn't work at all.
So, how can I have this shortcut?
These are the Comments options
Open Window>Preferences>General>Keys>type "add block comment" in the search box, you should see:
the type "remove block comment"
These settings are by default, but if the shortcut is not working on your machine, you must be missing these bindings, To create them, you need to mark the command "Add Block Comment", then click inside the "Binding" field and press CTRL+SHIFT+/, then press Apply. The same is for uncommenting.
I have a similar problem to the one you have: the / shortcut seems to trigger a folding operation (at least in the Java editor) that does not appear in the keys preferences table.
Modifying the key in the keys preferences table seems to work fine: setting the binding to Shift+Ctrl+Q for the "Add Block Comment" command sets the expected block comment.
The reason is clear to me: the Shift+Ctrl+/ binding is very difficult to reproduce in a Linux environment because Eclipse makes a clear difference Numpad_Divide and the '/'. The Normal '/' strike is being modified by the shift key (French keyboard).

Tell Eclipse to auto-complete only method name?

Let's say I'm editing a line...
obj.fooBar(x, y, z);
I want to change the method name to fooSomethingElse, but keep most of the arguments. If I delete all or part of the name, and then use content assist, it completes the method name, but starts a new arg list...
obj.fooSomethingElse(arg1, arg2)(x, y, z)
^---- this arg is highlighted for editing
I often have to delete "(arg1, arg2)". I can turn off "fill method arguments" in preferences and then I only have to delete "()", but it's still annoying. Is there another command to complete only the method name. Ideally it would just be a separate command and key combo from the general purpose content-assist, so I can invoke either one as needed.
Essentially you are looking for a way to toggle between inserting and replacing via content assist. The default behavior is to insert. You can toggle this behavior while inside the content assist selection dialog by pressing and holding the Ctrl key while selecting the completion.
More inforation - http://blog.deepakazad.com/2012/06/jdt-tip-toggle-between-inserting-and.html
I think you just need to press tab instead of enter to autocomplete it. Then it will keep your existing parameters.