# Save and revert changes

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com.cn/en-us/help/go/llms.txt).

GoLand automatically saves changes that you make in your files. Saving is triggered by various events, such as compiling, running, debugging, performing version control operations, closing a file or a project, or quitting the IDE. Saving files can be also triggered by third-party [plugins](managing-plugins.html).

Most autosave triggers are predefined. You can configure additional triggers in the settings. [Local History](local-history.html) can help you recover recent edits, but it has retention and size limits and does not replace version control or backups.

Procedure: Configure autosave behavior

1. In the Settings dialog (`Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Comma` (VSCode), `⌘ Comma` (VSCode (macOS))), select `Appearance & Behavior | System Settings`.

2. Under Sync external changes, configure the following options:

* Save files when switching to a different application or a built-in terminal: Save all modified files when you switch from GoLand to a different application.

* Save files if the IDE is idle for N seconds: Save all modified files after the IDE has been idle for the specified number of seconds.

3. Apply the changes and close the dialog.

Procedure: Mark files with unsaved changes

You can mark unsaved files on the file tab:

1. In the Settings dialog (`Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Comma` (VSCode), `⌘ Comma` (VSCode (macOS))), select `Editor | General | Editor Tabs`.

2. Select the Mark modified checkbox.

3. Apply the changes and close the dialog.

After that, the tab of the file in which you have unsaved changes will be marked with a blue dot.

If you use [version control integration](version-control-integration.html), names of all modified files will be also marked with a [dedicated color](adding-files-to-version-control.html#file_status) on the file tab and in the Project tool window.

## Save changes manually

Procedure:

You can always save your changes manually:

* Press `Ctrl+S` (Windows), `⌘ S` (macOS), `⌘ S` (IntelliJ IDEA Classic (macOS)), `⌘ S` (macOS System Shortcuts), `Ctrl+S` (XWin), `Ctrl+S` (GNOME), `Ctrl+S` (KDE), `Ctrl+X, Ctrl+S` (Emacs), `Ctrl+S` (Sublime Text), `⌘ S` (Sublime Text (macOS)), `Ctrl+K, S` (VSCode), `⌘ ⌥ S` (VSCode (macOS)) or select `File | Save All` from the main menu.

## Trigger actions when saving changes

In GoLand, you can configure the actions that will be triggered every time your modified files are saved.

Procedure:

1. To configure autosave actions for the current project,   in the Settings dialog (`Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Comma` (VSCode), `⌘ Comma` (VSCode (macOS))), open `Tools | Actions on Save`.

To configure the actions for new projects,  go to `File | New Projects Setup | Settings for New Projects | Tools | Actions on Save` in the main menu.

2. Select the checkboxes next to the actions that you want to trigger on save:

* [Reformat code](reformat-and-rearrange-code.html#reformat-on-save): reformat your code according to your current code style settings. This action is enabled by default for GoLand. When triggered, the IDE runs the built-in GoLand formatter and gofmt. > **Note:** > Also, you can use On Reformat Code action option (`Editor | Code Style | Go`, click Other tab). This option lets you invoke both formatters by pressing `Ctrl+Alt+L` (Windows), `⌘ ⌥ L` (macOS), `⌘ ⌥ L` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ L` (macOS System Shortcuts), `Ctrl+Alt+L` (XWin), `Ctrl+Alt+L` (GNOME), `Alt+Shift+L` (KDE), `Ctrl+Alt+L` (Emacs), `Ctrl+Alt+L` (Sublime Text), `⌘ ⌥ L` (Sublime Text (macOS)), `Alt+Shift+F` (VSCode), `⌥ ⇧ F` (VSCode (macOS)) whenever you want.

* [Optimize imports](creating-and-optimizing-imports.html#optimize-on-save) : remove unused imports and organize import statements according to your current code style settings.

* [Rearrange code](null): reorder code elements according to your current code style settings.

* [Run code cleanup](resolving-problems.html#code-cleanup): batch-apply quick-fixes from code cleanup inspections. Use the Project Profile drop-down list to select the inspection [profile](customizing-profiles.html) from which the IDE will run inspections.

* [Update copyright notice](copyright.html): update information in copyright notices in project files.

* [Run stylelint --fix](using-stylelint-code-quality-tool.html): fix the detected problems with Stylelint.

* [Run eslint --fix](eslint.html): fix the detected problems with ESlint. Enabling this option also enables [Run eslint --fix on save](eslint.html#ws_eslint_configure_run_eslint_on_save).

* [File Watcher](using-file-watchers.html): run your configured File Watchers .

* [Upload to default server](uploading-and-downloading-files.html) : upload modified files to your default deployment server. Enabling this option also enables [Upload changed files automatically to the default server](uploading-and-downloading-files.html#autoupload_definitions) .

3. For some actions, you can configure the settings more precisely. To do so, hover over an action and click the configuration link.

For example, you can specify files and folders that will be formatted when the file is saved. By default, the Go file type is selected. If you want to add other files types, hover over the action and click Files: Go.

4. Apply the changes and close the dialog.

Once the necessary actions are enabled, they  will be automatically triggered on every save (autosave, explicit save invoked with `Ctrl+S` (Windows), `⌘ S` (macOS), `⌘ S` (IntelliJ IDEA Classic (macOS)), `⌘ S` (macOS System Shortcuts), `Ctrl+S` (XWin), `Ctrl+S` (GNOME), `Ctrl+S` (KDE), `Ctrl+X, Ctrl+S` (Emacs), `Ctrl+S` (Sublime Text), `⌘ S` (Sublime Text (macOS)), `Ctrl+K, S` (VSCode), `⌘ ⌥ S` (VSCode (macOS)) or by selecting `File | Save All`) as you work with your project.

![Settings: Actions on save](https://resources.jetbrains.com.cn/help/img/idea/2026.3/go_actions_on_save.png)

## Revert changes

Procedure:

* For the most recent changes, including [refactorings](refactoring-source-code.html) , press `Ctrl+Z` (Windows), `⌘ Z` (macOS), `⌘ Z` (IntelliJ IDEA Classic (macOS)), `⌘ Z` (macOS System Shortcuts), `Ctrl+Z` (XWin), `Ctrl+Z` (GNOME), `Ctrl+Z` (KDE), `Ctrl+Shift+Minus` (Emacs), `Ctrl+Z` (Sublime Text), `⌘ Z` (Sublime Text (macOS)), `Ctrl+Z` (VSCode), `⌘ Z` (VSCode (macOS)) or choose `Edit | Undo` from the menu.

* For a more detailed view of past changes, use [Local History](local-history.html).

* For the most robust tracking of all changes, use a [version control system](version-control-integration.html).

## See also

### Procedures

[Version control](version-control-integration.html)

### Concepts

[Local History](local-history.html)

