7

When you hover over a variable in VS Code, e.g., a function name, there's a small pop up that shows where the function is defined and some other quick details. What is the name of this feature?

I'm setting up VS Code on a new computer, and I'm trying to get that feature, but not sure what it's called.

1 Answer 1

5

The built-in feature is aptly referred to as hover or hovers.

For example, the docs for the built-in Go to Definition mentions it as:

If you press Ctrl and hover over a symbol, a preview of the declaration will appear

It is also mentioned in various language-specific features, such as this one for HTML Hover:

Hover

Move the mouse over HTML tags or embedded styles and JavaScript to get more information on the symbol under the cursor.

HTML Hover

The relevant built-in settings are grouped by *.hover.*, such as:

// Prefer showing hovers above the line, if there's space.
"editor.hover.above": true,

// Controls the delay in milliseconds after which the hover is shown.
"editor.hover.delay": 300,

// Controls whether the hover is shown.
"editor.hover.enabled": true,

...

// Show tag and attribute documentation in hover.
"html.hover.documentation": true,

// Show references to MDN in hover.
"html.hover.references": true,

...

The contents however depend on the language of the file (as indicated on the status bar on the lower right of VS Code) and/or the extensions you have installed. For example, you said "shows where the function is defined", but for my Python workspaces, they typically just show the function signature and documentation:

sample hover popup for Python

So you would have to check both the built-in settings and the extension settings if you are looking for specific behavior/contents of the hover popup.

The way for extensions to modify the hover behavior/contents is also referred to as Show Hovers, and so it makes sense for extension-specific settings to refer to it as hover as well:

Show Hovers

Hovers show information about the symbol/object that's below the mouse cursor. This is usually the type of the symbol and a description.

animation of Show Hovers, taken from the VS Code docs

Sign up to request clarification or add additional context in comments.

4 Comments

Does Hovers come with "Intellisense?" I've found Intellisense extensions tend to provide this feature
@24n8 I would say, it's part of that same family of features. Intellisense is the more generic term not specific to VS Code, referring to features of an IDE that help you read/write code, like suggestions/autocompletion, highlighting, and info on mouse over. I did not mention it here because VS Code docs on Intellisense does not mention any mouse over or hover behavior: code.visualstudio.com/docs/editor/intellisense.
Ah I see. After I posted this, I installed an Intellisense extension (for C/C++ in my case) and that seemed to provide the hovers feature. Is the feature pretty flaky for you? I find sometimes it works and sometimes it doesn't and I'm not sure why.
@24n8 It works quite fine for me, though I don't do C/C++ anymore. It is indeed language and extension specific. Just the built-in one isn't that useful, so I think that's why VS Code provides a way for language extension authors to improve the behavior/contents. If you're having issues, you will probably have to report it to the extension authors.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.