WebStorm 2018.2 Help

Scratches

WebStorm provides a temporary editor. You can create a text or a piece of code for search or exploration purposes. WebStorm suggests two types of temporary files:

Scratch files
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
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 .txt type 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.

Create scratch files

  1. Do one of the following:
    • On the main menu, choose File | New Scratch File.
    • Press Ctrl+Shift+Alt+Insert.
    • Right-click anywhere in the Project Tool Window and choose New | New Scratch File from the context menu.
    • Press Ctrl+Shift+A, start typing scratch file.., and choose the corresponding action.
  2. Select the language of the future scratch from the list that WebStorm suggests. WebStorm 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.
  3. Type the desired code.

Create scratch buffers

  1. Start typing New Scratch Buffer:
    Find the New Scratch Buffer action
    WebStorm creates a temporary editor tab with the name buffer1. In the future, the default names will be buffer<number>.
  2. Type the desired code.

Observe the available scratches

  • To see the list of created scratch files and buffers, open the Project tool window and select Scratches and Consoles | Scratches:
    ws scratch files location
  • By default, scratch files and buffers are sorted alphabetically by their names and next by their extensions (types), which automatically means that buffer files always come first. To sort scratch files by types, click artwork studio icons logcat toolbar settings or right-click the Project tab and select Sort by Type:
    ws sort by type
    WebStorm sorts scratches alphabetically based on their extensions:
    ws scratches sorted by types

Close scratches

  • Click icons actions close on the editor tab. Refer to the section Editor basics for details.

Delete scratches

  • In the Project tool window, in the Scratches and Consoles | Scratches directory, select the scratch file or buffer you want to delete and choose Delete from the context menu.

Change the language of a scratch file

  1. In the Project tool window, click Scratches under Scratches and Consoles, and choose Change Language (<current language>) on the context menu of the scratch file to change the language for.
  2. Select the desired language. Note the following:
    • Four last used items are on top of the list, above the separator.
    • To narrow down the list, start typing the language name.
    • The Change Language action keeps extension in sync, if it exists.

Rename, copy and move scratches

To rename a scratch

  1. In the Project tool window, click Scratches under Scratches and Consoles,select the file to rename, and press Shift+F6.
  2. In the dialog that opens, type the new name. Note that specifying another extension does not affect the file type, use the Change Language action for that.

To copy a scratch

  1. In the Project tool window, in the Scratches and Consoles | Scratches directory, select the scratch file to copy.
  2. Press F5. In the dialog that opens, type the new file name. Here you can also specify another extension to change the file type. If necessary, select the folder where you want to save the copy.

To move a scratch

  1. In the Project tool window, in the Scratches and Consoles | Scratches directory, select the scratch file to move.
  2. Press F6 and select the target folder in the dialog that opens.

Important notes about scratches

Note the following:

  • The scratch code in scripting languages is executable: you can run and debug it.
  • Local History for scratches is supported.
  • It is possible to perform clipboard operations with scratches.
  • The scratches are stored, depending on your operating system,
    • Under WebStorm home, in the config/scratches directory (on Windows/*NIX)
    • ~/Library/Preferences/<WebStorm>XX/scratches (on macOS)
  • You can undo or redo changes in scratches.
Last modified: 13 June 2018

See Also