Reputation: 7318
In vscode when I mouse hover on let's say, a method call or property it will display some information. I can trigger same thing with keyboard shortcut CMD+H (on mac).
Now with the mouse when I hover while holding the CMD key it will display more information. How to trigger this (CMD+mouse hover) equivalent with keyboard ?
(I'm aware of ALT+F12, but it's not exactly the same trigger.)
Upvotes: 60
Views: 27004
Reputation: 1
The command you are looking for is "Show Definition Preview Hover". You can trigger it by searching for it in command palette (Ctrl+Shift+p) or set a keyboard shortcut to a command editor.action.showDefinitionPreviewHover
However, currently this command is bugged and doesn't work correctly: instead of extened preview, it shows the short one (same as just hovering without ctrl/cmd pressed). There is an issue for this filed on vscode's github: https://github.com/microsoft/vscode/issues/211640
Upvotes: 0
Reputation: 21
If you're using VSCodeVim, you can add this to your settings.json
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["g", "H"],
"commands": [
{
"command": "editor.action.showDefinitionPreviewHover"
}
]
}
]
By default if you enter gh
it will open in hover state.
I have it configured so that if I press gH
it shows me the advanced info.
Upvotes: 2
Reputation: 83
I think you are looking for keyboard shortcut for 'Definition Preview'.
Show Definition Preview Hover
editor.action.showDefinitionPreviewHover
To set a keyboard shortcut:
Show Definition Preview Hover
editorTextFocus
to when expressionOr you can append this to your keybindings.json:
{
"key": "ctrl+alt+;",
"command": "editor.action.showDefinitionPreviewHover",
"when": "editorTextFocus"
}
Here ctrl+alt+;
is shortcut key I have selected. You add your own.
Usefull reference: https://code.visualstudio.com/updates/v1_40#_definition-preview-hover-from-the-keyboard
Upvotes: 5
Reputation: 1105
Per official docs, the binding for 'Show Hover' is:
⌘K ⌘I
Remember that ⌘K is a 'chord', so do that first (Code will show "⌘K was pressed. Waiting for second key of chord..."), and then ⌘I.
Hope this helps. It's not the most elegant of bindings, but nothing to stop you changing it!
Note:-
For VSCodeVim users, this is: gh.
For Windows users, this is: Ctrl + K Ctrl + I
Upvotes: 108
Reputation: 141462
This answer elaborates on Jack's helpful answer by pointing out the command palette command and how to override its shortcut.
Open the command palette and type "show hover" to find the command.
The default shortcut does not work for me, so I added an override of Ctrl + Space + H.
To add your own override, open the command palette and type "keyboard shortcuts". That opens the shortcut editor. This is how mine looks.
// Place your key bindings in this file to override the defaults
[
{
"key": "ctrl+space ctrl+h",
"command": "editor.action.showHover",
"when": "editorTextFocus"
}
]
Upvotes: 14
Reputation: 292
There's a pull request to add this functionality, but it hasn't landed yet: https://github.com/Microsoft/vscode/pull/59260
Upvotes: 3