Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Visual Studio Code have an auto-import feature for Java??

Does VS Code have an auto-import function or hot key for Java?

I installed Java Extension Pack but I found that I need to import every library manually.

like image 908
user3698042 Avatar asked Nov 29 '18 08:11

user3698042


People also ask

Is Visual Studio Code OK for Java?

You can use VS Code to read, write, run, and debug Java source file(s) without creating a project. VS Code for Java supports two modes, lightweight and standard.


2 Answers

For organize imports inside a java file

press SHIFT+ ALT + O

The vscode has also the option of enable auto organize imports on save action

enter image description here

like image 65
Davijr Avatar answered Sep 19 '22 17:09

Davijr


Open the settings.json file (Ctrl+Shift+P than type settings.json) and add this:

"editor.codeActionsOnSave": {     "source.organizeImports": true },   

when you save it will works :D

Kudos: https://www.youtube.com/watch?v=svCTgx6abFc

like image 27
Renan Franca Avatar answered Sep 19 '22 17:09

Renan Franca