generated from oracle/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 61
VS Code Tips
Siddharth Srinivasan edited this page Dec 4, 2025
·
1 revision
- Use the Command Palette to run any command (see ways to open it below).
- Windows/Linux:
Ctrl+Shift+P - macOS:
Cmd+Shift+P - Press
F1 - Type
>in the Search bar at the top. - Menu:
View > Command Palette… - See also: VS Code - Get Started > User Interface: Command Palette
- Open Extensions:
Ctrl+Shift+X(Cmd+Shift+Xon macOS) or View > Extensions. - Search for "Java" and install the extension published by Oracle.
- Or, via Command Palette: "Extensions: Install Extensions" then search "Java".
- Or, via CLI:
code --install-extension oracle.oracle-java. - Reload VS Code if prompted.
- See also: VS Code - Get Started > Extensions
There are multiple ways to open VS Code Settings.
- Gear icon (bottom-left) > Settings
- Command Palette: "Preferences: Open Settings"
- Menu:
- Windows/Linux: File > Preferences > Settings
- macOS: Code > Settings > Settings (
Cmd+,)
- Open settings JSON:
- Command Palette: "Preferences: Open Settings (JSON)"
- Click "Open Settings (JSON)" in the Settings UI
- See also: VS Code - Configure > Settings
- Scopes (from lowest to highest precedence):
- Default settings i.e. Application settings.
- User settings i.e. VS Code user profile settings.
- Workspace settings
- Folder settings (in multi-root workspaces)
- Language-specific settings (e.g.,
[java]) override non-language settings at the same scope. - Effective value = highest-precedence matching scope, with language override applied last.
- CodeLens: Inline, clickable annotations above code (e.g., "Run | Debug", references count). Click to run code, debug, test or navigate.
- Suggestions/Completions (IntelliSense): Symbols, methods, imports, etc.; auto or via
Ctrl+Space. - Hints (Inlay/Parameter hints): Small annotations showing parameter names/inferred types.
- Configuration is possible for various features, including:
- Editor: CodeLens, Inlay Hints
- Java completion/suggestions/import settings
- Format Document:
- Windows/Linux:
Shift+Alt+F - macOS:
Shift+Option+F - Or right-click editor > Format Document
- Windows/Linux:
- Enable "Editor: Format On Save" for automatic formatting.
- See Configure Java formatter for defining your code style.
- Quick Fix / Code Action: Lightbulb or
Ctrl+.(Cmd+.on macOS) - Rename symbol:
F2(updates all references) - Extract method/variable/constant, inline, implement/override methods, organize imports:
- Right-click > Refactor…
- Command Palette: "Refactor…" or "Source Action…"
- Many refactors appear when you select code
- Organize Imports: Command Palette "Organize Imports" or enable via
Settings | Jdk › Java › On Save: Organize Imports.
- View > Output (
Ctrl/Cmd+Shift+U). - In the Output panel dropdown, select the Oracle Java channel (e.g., "Oracle Java SE Language Server"). If not visible, also check the "Extension Host" channel.
- For issues, also check View > Problems.
- Toggle terminal:
Ctrl+`(backtick) or View > Terminal. - Create/select terminals (Command Prompt, PowerShell, Bash, zsh).
- Run Maven/Gradle or
java/javaccommands directly.
- Use CodeLens "Run"/"Debug" above
mainmethods or tests. - Run menu:
- Run > Start Debugging (
F5) - Run > Run Without Debugging (
Ctrl+F5/Cmd+F5)
- Run > Start Debugging (
- Run and Debug view (
Ctrl+Shift+D/Cmd+Shift+D):- Click "Run and Debug" to auto-detect Java configs, or create a
launch.jsonfor custom configs.
- Click "Run and Debug" to auto-detect Java configs, or create a
- Optional: Use
tasks.jsonfor custom build/run tasks.
- Program output and input, as well as, debug logs and expression results are shown in the DEBUG CONSOLE tab (
Ctrl/Cmd+Shift+Y).
- Start a debug session (
F5or via CodeLens). - Use:
- Variables view for locals/globals
- Watch to track expressions
- Hover to see variable values inline
- Debug Console to evaluate expressions
- Call Stack and Breakpoints to navigate and manage conditions/logpoints