diff --git a/source/docs/software/vscode-overview/index.rst b/source/docs/software/vscode-overview/index.rst index f2de3303b4..a73255af60 100644 --- a/source/docs/software/vscode-overview/index.rst +++ b/source/docs/software/vscode-overview/index.rst @@ -12,3 +12,4 @@ VS Code Overview viewing-console-output debugging-robot-program importing-last-years-robot-code + organize-imports diff --git a/source/docs/software/vscode-overview/organize-imports.rst b/source/docs/software/vscode-overview/organize-imports.rst new file mode 100644 index 0000000000..e09721235d --- /dev/null +++ b/source/docs/software/vscode-overview/organize-imports.rst @@ -0,0 +1,32 @@ +Organize Imports +================ + +Visual Studio Code provides many settings to speed up programming. The Java extensions installed by WPILib allow for a setting to automatically insert the correct imports and organize them in your Java code when that file is saved. To enable this feature, first navigate to the user settings by opening the command palette with :kbd:`Ctrl+Shift+P`, then type User Settings (JSON) and press enter. Finally, add this section of code to the end of the user settings. + +.. code-block:: json + + "editor.codeActionsOnSave": { + "source.organizeImports": "explicit" + }, + +The end result should look something like this. + +.. code-block:: json + + { + "java.jdt.ls.java.home": "C:\\Users\\Public\\wpilib\\2024\\jdk", + "extensions.autoUpdate": false, + "extensions.ignoreRecommendations": true, + "update.mode": "none", + "update.showReleaseNotes": false, + "http.systemCertificates": false, + "terminal.integrated.env.windows": { + "JAVA_HOME": "C:\\Users\\Public\\wpilib\\2024\\jdk", + "PATH": "C:\\Users\\Public\\wpilib\\2024\\jdk\\bin;C:\\Users\\Public\\wpilib\\2024\\jdk\\bin;C:\\Users\\Public\\wpilib\\2024\\jdk\\bin;C:\\Users\\Public\\wpilib\\2024\\jdk\\bin;${env:PATH}" + }, + "editor.codeActionsOnSave": { + "source.organizeImports": "explicit" + }, + } + +Now whenever you save your files with :kbd:`Ctrl+S` or by clicking Save under the File dropdown, the necessary imports will be automatically inserted into your Java code for any classes you're using. If there is an ambiguous import, a dropdown will be provided for the user to select the correct one.