5

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

  • Ctrl+K Ctrl+I doesn't actually do anything for me... I'm trying to get the hover text to show. My keybindings are correct... – mbomb007 Jul 08 '22 at 18:26

3 Answers3

1

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.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Unfortunately that is not what I wanted to do. My final goal was to open the hover, select text, copy text and close the hover for later pasting. Your way, without mouse (Ctrl+A), copies the whole hover text. Ok, one might say it better than nothing. But the Ctrl+A Shortcut does not copy the hover text, at least on my linux machine. It copies the open code file instead where the hover was actually opened. So even the workaround does not work for linux. – MergeMaster Jun 20 '22 at 11:19
  • @MergeMaster From what I understand, Ctrl+A was never about copying, only about selecting. – VonC Jun 20 '22 at 11:24
  • You are right. It was about selecting before copying. So Ctrl+A followed by Ctrl+C. But the point is, that although the hover is focused Ctrl+A does not select the hover text. It selects the code from which the hover was opened (the code file itself). At least on linux. – MergeMaster Jun 20 '22 at 12:06
  • @MergeMaster On Linux, with the latest 1.68? – VonC Jun 20 '22 at 13:00
  • Yepp, Vscode "Update 1.68.1" Ubuntu 20.04. – MergeMaster Jun 20 '22 at 13:35
1

Think I found out what you were after.

The shortcut is: Ctrl+K Ctrl+I

See: Trigger advanced hover information with keyboard

Saeid Amini
  • 1,313
  • 5
  • 16
  • 26
binboukami
  • 11
  • 2
  • If you think that this contributes additional insight, especially in comparison to https://stackoverflow.com/a/72514533/7733418 then you will have to [edit] in order to make that more obvious. – Yunnosch Sep 24 '22 at 18:05
0

please try control + mouse click it may be help you

Mirza
  • 3
  • 1
  • 4
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 30 '21 at 10:53