Access mouse over hover in VSCode

Viewed 542

Is there a way to access the mouse over popup in VSCode via Keyboard and navigate in it? I often use the mouse over to get the namespace of function or variable ... So I want to place the cursor on "bar", popup the hover (Show Hover Ctrl+k Ctrl+i), focus it, mark some text (eg. namespace::functioname), copy and close the hover.

namespace foo{
  void bar(); 
}

First problem, the hover doesn't get the focus and I don't know how to focus it. But there is another feature "Show defintion preview hover", which actually gets focused. So far so good. But I still cannot mark or copy text inside the hover via keyboard.

Show hover (not focused):

enter image description here

Show definition preview hover (focused):

enter image description here

3 Answers

But I still cannot mark or copy text inside the hover via keyboard.

That should change with VSCode 1.68 (May 2022):

Lock hovers to more easily mouse over them

Some custom hovers cannot be moused over and others are tricky to mouse over without hiding it because of other things in the way (eg. like a scroll bar).

Holding alt while a hover is active will now "lock" it, giving it a wider border and preventing moving the mouse outside of the hover widget or whatever triggered it from hiding it.

This is primarily an accessibility feature to make hovers play nice with screen magnifiers but it is also useful for copying text from certain hovers.

hover

Note that this feature only applies outside of the editor because editor hovers can always be moused over unless specified otherwise via a setting.

This will be helpful for other views (debug, terminal, ...) where variables with their popup can appear as well.

In the editor, see microsoft/vscode issue 63296

  • ctrl+K ctrl+I to show the hover and focus it
  • ctrl+A to select all the hover content
  • ctrl+C to copy to clipboard

It does indeed work for me (on windows) for the first two steps, however ctrl+C does not copy the text selected with ctrl+A.

It seems like there are two different selections possible in the hover:

  • ctrl+Aselects everything with a dark blue.
    When selecting some text in the hover with the mouse (i.e. press the left mouse button while near/over a char, move mouse, release left mouse button) the selected text is shown in a lighter and brighter blue.
    The two selections can coexist.
  • ctrl+C always copies the text selected with the mouse, or nothing if there's no such selection, no matter whether a ctrl+A selection also has been done.
    If there's only a ctrl+A selection, ctrl+C doesn't copy anything.

https://user-images.githubusercontent.com/2768898/82740165-8867d880-9d46-11ea-945c-c9aa8fa9676e.png

The two selections can be selected in any order. The order doesn't change the behavior.

please try control + mouse click it may be help you

Related