Where are IntelliJ scratch files located?

18.6k views Asked by At

In IntelliJ IDEA 14, we can create scratch files from Tools > New Scratch File...

Are they stored in some temporary files? If the answer is yes, where are they?

Attempts:

1) I pressed right click > Copy Reference and I pasted it:

1d0b26a2/scratch.2:1

2) I opened .idea\workspace.xml and I have the following part for scratch files:

  <file leaf-file-name="scratch.2" pinned="false" current-in-tab="true">
    <entry file="scratchpad://1d0b26a2/scratch.2">
      <provider selected="true" editor-type-id="text-editor">
        <state vertical-scroll-proportion="0.0" vertical-offset="0" max-vertical-offset="636">
          <caret line="0" column="0" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="20" />
          <folding />
        </state>
      </provider>
    </entry>
  </file>

For a normal file the entry path starts with file:// instead of scratchpad://.

8

There are 8 answers

0
ROMANIA_engineer On BEST ANSWER

I upgraded my IntelliJ IDEA to 14.1 and I found the scratch files.

If you create a scratch file, its path can be found in many different ways:

  1. On the title bar

  2. Right click on the tab > Copy Reference

    enter image description here

    You can paste it anywhere and it will look like:

    C:/Users/username/.IntelliJIdea14/config/scratches/scratch

  3. Right click on the tab > Rename File...

  4. Right click on the tab > Local History > Show History

  5. In .idea\workspace.xml it looks like:

    <file leaf-file-name="scratch" pinned="false" current-in-tab="false">
      <entry file="file://$APPLICATION_CONFIG_DIR$/scratches/scratch">
        <provider selected="true" editor-type-id="text-editor">
          <state vertical-scroll-proportion="0.0">
            <caret line="4" column="17" selection-start-line="4" selection-start-column="17" selection-end-line="4" selection-end-column="17" />
            <folding />
          </state>
        </provider>
      </entry>
    </file>
    
3
Christopher Thomas On

@rolf wrote this comment and I want to promote it as the answer here cause it's not already written. But the best way is to

Opening accidentally closed scratch files can be easily done with Cmd-E, which shows the "Recent Files" popup. Closed scratch files show up there. – Rolf

Thanks rolf!

0
Rolf On

Opening accidentally closed scratch files can be easily done with Cmd-E, which shows the "Recent Files" popup. Closed scratch files show up there.

0
Najki On

Here's another solution if you can't find your scratch files in the Scratches tab as @fnt suggested (which normally is the most convenient way probably).

In my case, I've recently updated my editor from PhpStorm 2018.1 to PhpStorm 2018.2. The scratch files are saved along with all preferences in a path specific to each version of your editor. In case of MacOS it's ~/Library/Preferences/PhpStorm2018.2.

This means that when you update your IDE, it starts using the new path and it doesn't see your old scratches anymore. If you still need to open them, simply navigate to path specific for your OS and all you're scratches are there.

All paths, are listed in official docs.

0
Husterknupp On

enter image description here

~/Library/Application\ Support/JetBrains/IntelliJIdea2020.1

for macOS this is the location of both

  • database consoles (all the neat little db helper scripts)
  • scratch files (stored as plain files, a scratch you created in your idea app under the name scratch.py you will find in this directory as scratch.py)

To migrate your scratches, you just need to copy over these directories to your new environment under the above mentioned path.

However, please mind that this works for IntelliJ version 2020.1 on macOS. I'm not 100% sure where earlier versions used to store scratches and on other operating systems.

0
ᄂ ᄀ On

Starting with 14.1, Scratch Files are stored under .IntellijIdea14/config/scratches.

They are displayed either in Scratches and Consoles or on the Scratches tab (depends on the version you are using).

Current UI:

Scratches and Consoles

Earlier UI:

Scratches tab

IntelliJ IDEA Help - Scratch files

0
Yidir On

You can switch to project view and you'll be able to see them under "Scratches and consoles"


WebStorm project view

0
eloqz On

For any linux users getting here:

I found my PyCharm scratch files in ~/.config/JetBrains/PyCharm2022.3/scratches