GoLand provides a temporary editor. You can create a text or a piece of code for search or exploration purposes. GoLand suggests two types of temporary files:
- Scratch files
- The scratch files are fully functional, runnable, debuggable, etc. They require a language to be specified and have an extension. The scratch files are created via Ctrl+Shift+Alt+Insert.
- Scratch buffers
- The scratch buffers are only intended for pure editing, and as such they do not require specifying a language and do not have an extension. The scratch buffers belong to
.txttype by default.
This action has no dedicated shortcut, but you can configure one as described in the section Configuring Keyboard Shortcuts.
Buffer files are reused after creating 5 files. After reuse, the content and language are reset.
Creating scratch files
To create a scratch file
- Do one of the following:
- On the main menu, choose .
- Right-click anywhere in the Project tool window, and choose
- PressCtrl+Shift+A, start typing
scratch file.., and choose the corresponding action.
- Select the language of the future scratch from the list that GoLand suggests. GoLand creates a temporary editor tab with the name
scratch.<extension>. In the future, the default names will be
scratch_<number>.<extension>. The scratch file is added to the Scratches and Consoles directory located in the Project tool window.
- Type the desired code.
Creating scratch buffers
To create a scratch buffer, follow these steps:
- Press Ctrl+Shift+A or search everywhere.
- Start typing the command name
New Scratch Buffer:
GoLand creates a temporary editor tab with the name
buffer1. In the future, the default names will be
- Type the desired code.
Observing the available scratches
To see the list of created scratch files and buffers, open the Project tool window and select .
To sort scratch files by types, right-click the Project tab and select Sort by Type. GoLand sorts scratch files alphabetically based on their extensions.
To close a scratch file or buffer, just click on the editor tab. Refer to the section Editor basics for details.
To delete a scratch file or buffer, in the Project tool window, in the directory, right-click the scratch file or a buffer you want to delete and from the context menu choose Delete.
Changing the language of a scratch
If you want to change the scratch's language when a scratch is already created, you can do so with the aid of the editor's context menu. This is how it's done:
- In the Project tool window, in the , right-click the scratch file for which you want to change the language.
- From the context menu, select .
- Select the desired language.
Note the following:
- Four latest items appear on top of the list before a separator.
- You can narrow down the list by typing the language name.
- action keeps extension in sync, if it exists.
Renaming, copying and moving scratches
GoLand makes it possible to perform Rename refactoring of the scratches. To rename a scratch, follow these steps:
- In the Project tool window, in the directory, select the scratch file to be renamed.
- Press Shift+F6.
You can also perform renaming in the other ways:
- In NavBar: Jump to NavBar ( Alt+Home ) -> Rename ( Shift+F6 ).
Copy and Move file actions are available the same way. Refer to the sections Move and Copy for details.
Note that when copying a scratch, GoLand includes the respective extension that corresponds to the file type. This is how it's done:
- In the Project tool window, in the directory select the scratch file to be copied.
- PressF5. GoLand shows the appropriate dialog.
This dialog box shows the scratch name with the corresponding extension. Note that when you copy a scratch buffer, the extension is