WebStorm 2018.2 Help

Scratches

Sometimes you may need to create temporary notes or draft up some code outside of the project context. Instead of switching to a different application for this purpose, you can use scratch files and scratch buffers.

  • Scratch files are fully functional, runnable, and debuggable files, which support syntax highlighting, code completion, and all other features for the corresponding file type. For example, while working on one project, you may come up with an idea for a method that you could later use in another project. You can create a scratch file with a draft of the method, which is not stored in your project directory, but can be accessed and opened from another project. You can use scratch files to draft code constructs, HTTP requests, JSON documents, and so on.

  • Scratch buffers are simple text files without any coding assistance features. Scratch buffers can be used for simple task lists and notes to yourself. They are also not stored in the project directory, but can be accessed and opened from another project. You can create up to five scratch buffers with default names, which are rotated and reused by clearing the content.

Create scratch files

  1. Do one of the following:
    • Press Ctrl+Shift+Alt+Insert.
    • Press Ctrl+Shift+A, start typing scratch file and then pick the corresponding action.
  2. Select the language of the scratch file. Scratch files of the same type are automatically numbered and added to the Scratches and Consoles directory of the Project Tool Window

Create scratch buffers

  • There is no dedicated menu item for the action to create a new scratch buffer, but you can use the Find Action popup (Ctrl+Shift+A) and run the New Scratch Buffer action.
    Find the New Scratch Buffer action

View 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

View documentation for scratches

  • Select any scratch file or buffer and press Ctrl+Q to view quick documentation with the location, type, size, creation and modification date of the file.

Rename scratches

  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.

Copy scratches

  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.

Move scratches

  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.

Change the language of scratches

  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.
Last modified: 14 September 2018