How do you auto import libraries in Visual Studio Code? - visual-studio-code

Usually in IntelliJ you have a shortcut for auto importing libraries.
Is there an equivalent for Visual Studio Code?

In the current version, 1.11.2, you can put your cursor in the error line.
You will see a bulb in the line number. Then click it or press the shortcut ⌘ + . (Quick Fix).
That will pop up a import hint window, as follows

Currently there is no support for this in Visual Studio Code, but it's a good idea for an extension.

Related

How to Show Code Runner Shortcut In VS Code

How can I show the Code Runner shortcut in Visual Studio Code if I mistakenly hid it?"
I was using Visual Studio Code and I accidentally hid the Code Runner shortcut. Is there a way to show it again? I have tried searching in the keyboard shortcuts settings but can't seem to find it. Any help would be appreciated (P.S I Know Many Of You will Say Use a Shortcut Key, or Reinstall the CodeRunner & VS Code But All Is Not Working)
How Can I get Code runner Shortcut Again
Make sure that you enabled your "Code Runner" extension
Go to the top right corner of VS Code to find a button that looks like three dots (...)
Right click on it and press "Run Code"
The Run Code button should reappear now

How do I prevent autocomplete on spacebar in Visual Studio Code (VS Code)?

In Visual Studio Code when a highlighted quick suggestion appears, if I press SPACE, the suggestion is accepted and auto-completed.
How do I disable this feature so autocomplete only occurs on TAB and ENTER (the other default completion keybinds as of 2022.7.16)?
Add the following line to your VS Code settings JSON file.
"editor.acceptSuggestionOnCommitCharacter": false
Sourced from a similiar question about Visual Studio - source answer.

How can I "Add Next Occurrence" in Visual Studio for Mac?

In Visual Studio Code and Sublime Text there is functionality called "Add Next Occurrence" that selects next occurrence of marked text. The keyboard shortcut for utilizing this function is CMD+D (CTRL+D on Windows and Linux).
This function would select the next occurrence of the text and also add another cursor to the end of the newly selected text.
How can I achieve this in Visual Studio for Mac?
The shortcut is: ⇧ + ⌥ + .
(Shift + Option + .)
And its name in the settings is: "Insert next matching caret"
At the moment this answer is the only one working for Visual Studio (tested in 8.9). All the others are for Visual Studio Code.
Unfortunately, this is not currently supported. There is however an open suggestion to the team that you can up-vote if you would like to see this feature in an upcoming release.
Here is the link to the feature request: https://developercommunity.visualstudio.com/content/idea/351843/multiple-selection-with-the-keyboard.html
In Mac, CMD + D will do the job.

How to apply bookmarks with a mouse click event on VisualStudioCode?

I have Visual Studio Code(VSCode) 1.10.1 version installed on Windows 7. I am new to VSCode.
At the moment, if I click on the left side of a file before the line numbers, a red dot appears which is the breakpoint. But, how to replace breakpoint with bookmark instead? It does work with ctrl+alt+k. But, I prefer a mouse click to apply bookmarks.
I searched through the settings.json file. Couldn't find anything relevant to this.
Press F1 in VSCode, type ext install and then look for Bookmarks.
For details check this - Are there bookmarks in Visual Studio Code?

How do I toggle header/cpp file via keyboard shortcut in Visual Studio Code?

I'd like a simple keyboard shortcut to swap between the header (h, hpp) and CPP files. Visual Assist for Visual Studio allowed me to do this via ALT+O. Is there a similar keyboard binding for Visual Studio Code?
You can use the extension ms-vscode.cpptools to Switch Header/Source. If you're on Mac, then the shortcut is ⌥ O (option + O key). On windows, the shortcut is Alt+O.
Old answer:
There are currently a couple of extensions that support header/source file toggling:
bbenoist.togglehs
ryzngard.vscode-header-source
You can find more by searching the words "switch toggle header source" in the extensions tab in vscode.