Where are IntelliJ scratch files located? - intellij-idea

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://.

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:
Earlier UI:
IntelliJ IDEA Help - Scratch files

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:
On the title bar
Right click on the tab > Copy Reference
You can paste it anywhere and it will look like:
C:/Users/username/.IntelliJIdea14/config/scratches/scratch
Right click on the tab > Rename File...
Right click on the tab > Local History > Show History
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>

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

~/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.

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.

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 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!

Related

Intellij Load Settings error

After a computer crash i get the following error in Intellij:
Cannot load settings from file 'C:\Users\*\.IdeaIC14\config\options\mavenVersion.xml': content truncated
File content will be recreated
What I've tried to no success: clearing \caches folder, deleting mavenVersion.xml file.
Please help restoring peace in Intellij IDEA!
In my case, there were Intellij and Android Studio installed on my machine.
I deleted the .idea dir in the project. Opened the project in Android Studio. Closed it. Then everything was fine in IntelliJ.
I am pasting the contents of my mavenVerison.xml file for you - please recreate the file with this contents, in the specified location, and give it another try.
<application>
<component name="MavenVersion" version="3.x" vmOptions="-Xmx512m" embedderJdk="#JAVA_INTERNAL" />
</application>
Note that I am using maven 3.x.
If this doesn't work, and if you don't mind reconfiguring your environment again, stop IntelliJ, move the entire .IdeaIC14 folder to some place else, and restart IntelliJ.

Notepad++ workspace refresh?

How do i refresh the workspace / project in notepad++ when the file-system changes ( files and folders added or removed ).
at the moment it does not keep up with the local file system and i have to re-create the project each time!! frustrating..
I followed Rechtar's suggestion.
I had a similar issue. Notepad++'s Project pane doesn't update when I change or create new files. What I ended up doing was downloading the explorer plugin through
PLUGINS > PLUGIN MANAGER > SHOW PLUGIN MANAGER
Then install the explorer plugin.
After it's installed go to PLUGINS > EXPLORER and select the explorer.
It's not really comparable to something like Eclipse's project navigation.
In Notepad++ 7.5.8, this issue has been fixed. I suggest you update your notepad++ to the latest version.
In order to do this, go to ? -> Update Notepad++ and it will automatically detect a new update package. Update Notepad++ normally.
Otherwise, you could download the update from here:
https://notepad-plus-plus.org/news/notepad-7.5.8-released.html
In case you're curious, here's the changelog for 7.5.8:
Notepad++ v7.5.8 bug-fixes:
1. Remove annoying "no update" notification.
2. Fix Folder as Workspace not updating regression.
3. Fixed crash issue by checking & unchecking "Disable extension column" option in preferences dialog.
4. Fixed a crash when trying to launch a secondary instance with command line arguments.
5. Fix "Explorer Here" from "Folder as Workspace" problem if folder name contains comma.
Included plugins:
1. NppExport v0.2.8 (32-bit x86 only)
2. Converter 4.2.1
3. Mime Tool 2.1
4. DSpellCheck 1.3.5
Updater (Installer only):
* WinGup (for Notepad++) v5.0.2
I'm currently running version 6.3.3 of notepad ++ and instead of adding the entire project all over again, you can right-click the folder in your project that has the new file and choose: "Add files...". From there, you can select your new file and open it. This will add it to your project in the appropriate folder.
There doesn't seem to be a proper way to do this in Notepad++. The Project panel was born just 2 or 3 releases ago, so it's naturally immature. I suggest that you install either the Explorer plugin or the Light Explorer plugin - they are much more usable.
Or better yet, go learn Vim and fall in love with the NERDTree ;-)

Folders missing in project pane in Webstorm

I've built a project in WebStorm and then submitted the project to GitHub.
When I rebooted the computer and relaunched WebStorm (and the project), all I can see in the project pane is the root files, and none of the folders (yes the folders are there)
See the image below for reference.
Does anyone know how I can get those folders to re-appear in the project pane of Webstorm?
It can be caused by the corrupted .idea/modules.xml project file. You can either try to fix it manually (restore from Local History, version control or backup) or create the new project from scratch.
Check this issue for the hints/workarounds.
It happens sometimes in WebStorm 9.
The easiest way to fix it for me:
close WebStorm;
in project's folder remove .idea/ (hidden directory);
open your project, enjoy:)
Solution:
Creating a new project from existing sources
File => New => Project
Select "Empty Project"
Browse to the location of your project with folder issues
Click "Create"
Select "Create from Existing Sources" in the "Directory Is Not Empty" dialog
Why this solution:
Editing and deleting in various combinations of .idea and XML files did not solve the issue for me. Hence the solution above. Back up your .idea directory in case you have project customizations you want to keep. This likely overwrites them.
Outcome:
All the various folders I had created were now visible and the project worked as expected. The .idea directory was now formatted correctly with all the necessary files.
Find the .idea/modules.xml in your project root
make sure that these lines are correct :
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/NameOfYourProject.iml" filepath="$PROJECT_DIR$/.idea/NameOfYourProject.iml" />
</modules>
Replace NameOfYourProject.iml with the name of your project.
Then, make sure that the file .idea/NameOfYourProject.iml exists, if not , create it and put this in it :
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library name="PHP">
<CLASSES>
<root url="file://$MODULE_DIR$/../../php/PEAR" />
</CLASSES>
<SOURCES />
</library>
</orderEntry>
</component>
</module>
You do not need to delete whole .idea folder and reconfigure your whole project, just
delete the .idea/modules.xml
restart the IDE and your folders are there again!
I ran into the same issue and resolved it by invalidating the cache.
The option is under File > Invalidate Caches/Restart.
On the prompt click Invalidate and restart.
Note: The project in concern needs to be open before you do this.
I see this from time to time. I use Git, and I have my .gitignore file set up as recommended, specifically:
.idea/workspace.xml
.idea/tasks.xml
.idea/*.iml
I sometimes see this after cloning the repository, and when trying to figure out why, I came across this post and read the accepted answer.
I deleted the modules.xml file and reopened WebStorm (2016.2.4), and it was resolved. I looked at the new modules.xml and found that its contents were exactly the same as before, but my <projectName>.iml file was bigger.
So it seems to be a corruption in the .iml file, not modules.xml. I assume that deleting modules.xml triggers a rebuild of the .iml file. Not sure if this helps anyone with anything, but thought I would offer the extra insight.
floor 36 solve my problem. in WebStrorm 11
It happens sometimes in WebStorm 9. The easiest way to fix it for me:
close WebStorm;
in project's folder remove .idea/ (hidden directory);
open your project, enjoy:)
Try deleting workspace.xml and watchertask.xml then just restart the IDE. You must see your full source code in all folders there.
Finally I found the culprit, it was Team Foundation Server - Version Control Integration plugin from https://plugins.jetbrains.com/plugin/7961-team-foundation-server--version-control-integration/
I looked at the system/log/idea.log file and found that this plugin was producing Null exception whenever I open a new folder as a new project and breaks the content root auto detection by the IDE, and after I uninstalled this plugin, all folders show up as it should.
You might have this issue because of a culprit plugin, and disabling those which you have just installed recently just before this issue occurs, will resolve the issue. Check the log file and search for ERROR.
If it is found to be an important plugin you are actively using which you are not willing to disable, then a temporary fix is to open Settings->Directories and click Add content root button to add the root folder of your project, click Ok now folders will show up and indexing will begin, and of course you have to do this everytime you open a new folder as new project.

All IntelliJ run configurations disappeared

After IntelliJ IDEA froze and was killed from the task manager, all the Run/Debug Configurations disappeared. I have tried invalidating caches, reloading files from disk, synchronizing and restarting, but nothing helped.
You can try to restore your Run configuration using the Local History feature of IntelliJ IDEA.
If you are using .idea directory based format, then your configurations will reside in workspace.xml file under .idea directory, invoke Local History dialog from the .idea directory right click menu in IDEA Project View, select the label some time before the crash and revert the old copy of workspace.xml.
In case .ipr file based format is used, your configurations will be stored in the <project>.iws file in the project root which you can restore in a similar way.
If the configurations were Shared, they are stored in .idea\runConfigurations directory as separate XML files or in the <project>.ipr file (if old project format is used).
If the Local history is blank and you are in Windows, try Restore previous versions right clicking the workspace.xml file or the <project>.iws one in Windows Explorer.
You can go to your main project and right click on it, select local history --> show history. Find some point in time where you think that system was stable (before crash) and click revert. This worked for me.
To me, this frequently happened on switching branches. Turning off "restore workspace on branch switching" helps to prevent the run configurations from getting lost.
Edit: Not sure if it actually has an impact, it still seems to happen to me sometimes, maybe less frequently though. I'll leave it here since the answer already has some upvotes, so maybe this was the solution for someone...
For every project in intellij there's a file created with all the configurations related to it.
Under the root directory of the project there's a hidden folder .idea in it is the workspace.xml with the configuration. workspace.xml is comprised of components one of which is responsible to hold the run/debug configurations.
If this file is getting corrupted it's difficult to restore these configurations if you don't have a backup of workspace.xml. to overcome it:
1. in intellij right click the workspace.xml file under project view and choose Local History -> Show History
2. if there's no history you can copy the component from a coworker with similar configurations.
3. backup in advance the workspace.xml and retrieve the RunManager component from it..
another good choice is to use the share option.
under each project's definition there's a checkbox share
Marking this checkbox will extract the definition for this project to an external location:
under the same .idea folder a new folder is being created runConfigurations and the configurations per project are being represented there in xml files.
The advantage of using share is that it can be copied and used for similar projects under other branched like QA and production
In my case, i've accidentally pressed Alt + Home and this bar disappeared, this combination toggles run bar at the top of IDEA window for me.
Here the screen with my bound actions on this keys. I hope it should help
Run configurations are stored in your project files. When IntelliJ (or your computer with IntelliJ running) crashes hard, the project files can become corrupted and unreadable. I don't know of a way to recover this unless you have your project files are backed up somewhere.
Navigate to your project folder and check weather any .idea folder is created or not,
if created copy your project and paste it other location ant try opening it;
it will work.
I sometimes have the problem that all the run/debug configurations are not created from CMake after being lost. I solved this by just deleting the whone list of configurations from the workspace.xml (from .idea folder).
This happened to me recently and I just restarted IntelliJ and they shared ones (in .run) are now restored.
In my case what happened was I did something that made IntelliJ recognize the project as a new application type, so it thought my old configuration was not valid for my project anymore and wasn't displaying it to me. I reverted my changes and the configuration appeared as an option again.
I guess this feature can't be removed from IntelliJ but I guess this can help:
Run/Debug configuration functionality might be hidden, so to show it go to:
View/Appearance/Navigation Bar
Very annoying problem in Intellij Idea for many years.
It's quite often breaks because of broken (connection to?) Ant debugger, used to create run configs.
I was periodically searching for a solution, but no success. Then today after disappeared Run Config to display in panel I did inspect contents of workspace.xml. All the run configs were there.
And then it turns out to be 7+ years bug clue...
Always spring out non-called Ant...
Happily, contents of workspace.xml in place with all your run config items, you can just
disable infamous plugin Ant debugger,
reload the project,
and all your run configs are displayed and available again))).
Happy to share with all of you the solution).

Disable intellij indexing on specific folder

In my project I have .deploy folder which is created/updated when I deploy my app locally. Is it possible to disable indexing on that folder? Everything slows down whenever I deploy and it's really annoying - I have to wait a few minutes whilist intellij doing unnecessary indexing. In module view I excluded that folder but it's not helping. Any help would be appreciated.
Mark this folder as Excluded in the File | Project Structure | Modules | Sources tab.
Edit: also make sure it's not added as a library in the project.
On IntelliJ 13+ (don't know for earlier versions), you can right click on a folder > Mark Directory As > Excluded.
if you cannot do it throu the Modules menu because your intellij freezes (like in my case) edit .iml file of your projet and add excludeFolder line as below:
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/features" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<excludeFolder url="file://$MODULE_DIR$/node_modules" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
The option is now called Stop/Start Index, available from the folder context menu in solution explorer. When index is stopped, the folder will appear with "no index" annotation on the right.
I excluded the build output folder and no longer getting lengthy index refreshes after each build. Also full text search is a lot faster (near instant).
After applying the Mark As > Excluded method to a folder you still might see unwanted results.
You have to explicitly mark sub-folders as well to disable certain functionalities for sub-folders.
indexing, find usages etc.
Sometimes it is not possible to mark the folder as excluded. It happens with direct node dependencies.
For that, it's a bit extreme but you can add it to Editor-> File types -> ignored file types and folders. It won't be indexed at all. It won't be shown in the project either