Finding a scratch file in IntelliJ IDEA - intellij-idea

I would like a quick way to open a given scratch file.
For example. If I have a notes.md scratch. It does not show up using:
cmd + n then typing notes.md
shift + shift then typing notes.md
The only way I know to find them is by choosing Scratches in the Project tool window as described here: IntelliJ IDEA Help. This is painfully slow. Especially given that the whole purpose of a scratch is that it is a quick place to store something.

In case anyone comes across this thread like I did:
You can use File > New > Import Module from Existing Sources... on the existing directory where Intellij keeps the scratch files. This will create a "scratches" module in your project, which forces indexing of its contents. In my case, they're in C:\Users\jacob.hanson\.IntelliJIdea2019.1\config\scratches. You can find the full path by right clicking an existing scratch file in the project view and choosing Show in Explorer.
It's not the prettiest solution, but it preserves the default location of the scratches and keeps from having to increase the 'Recent File' buffer limit.
scratch files will appear in your Shift Shift searches!

I've run into the same problem and have tried increasing the file limit to a ridiculously high number, but I was feeling that contributed to sluggish behavior as the buffer grew.
Since then, I've discovered the Scratch plugin by dkandalov which has much better scratch file management (albeit using an entirely different implementation?).
https://plugins.jetbrains.com/plugin/4428-scratch

Related

How can I export and share my IDEA bookmarks and Favorites

Is there a way to export my IntelliJ IDEA favourites for backup, or to share with colleagues, like the way I can export my code formatting preferences (File > Export Settings)?
I'm working on a large codebase (one IDEA project), and have to switch between different new feature tasks and bug fixes, so I find it really convenient to create new Favourites list per Task or Jira ticket.
My Favourites tab is full with tens of favourite lists, and it's getting harder everyday to browse through them. So I could organise my work better if I could export them (ideally a different export per task, but grouping them is OK too), and reimport when I need to work on them again.
Any alternative suggestions are welcome. Thanks
#Eugene Morozov Fortunately yes !
And I must admit that I'm very disappointed in the fact that there is no IntelliJ team support for this topic,
or some guidance to help people, as this happens pretty much after all new versions of IntelliJ and it's update,
and as a consequence, it impacts a developer's work, at least for us who work on really big projects.
So I've decided, to make this short tutorial how to restore back your bookmarks for Windows 10 users :
As of version 2020.1, IntelliJ operates under hidden Windows user AppData folder :
e.g. C:\Users<windows.user.name>\AppData\Roaming\JetBrains\IntelliJIdea\workspace
Even more, under C:\Users<windows.user.name>\AppData\Roaming\JetBrains there are previous versions, (along with backup folders !)
and under appropriate version, in folder "workspace" there are all modifications, in the form of <funny_ssh_like_fileName>.xml
(e.g. 1lFTpsTT6pUo3tksBtYpwaD5qZ2.xml)
So, in my case, I've :
opened ~\AppData\Roaming\JetBrains\IntelliJIdea2020.3\workspace
sort files to descend based on modified flag
opened the newest one, and found that there is just one new bookmark, without previous ones !
so, I opened next recent xml, found and copied everything in between,
into the current IntelliJ workspace file
(Note this answer may now be out of date)
Bookmarks come under <component name="BookmarkManager"> in the .idea\workspace.xml. (Since the answer was posted the location changed to AppData)
But the problem is that:
If you try to use the bookmarks on a file that has changed, the line numbers the bookmarks point to will likely have changed and the links are broken.

Emacs equivalent of Xcode's "Open Quickly"

I'm trying to get a Cocoa development environment working in Emacs, and I'm 80% of the way there. The one feature I miss is Xcode's "Open Quickly", which basically performs a fuzzy match of the string you type against the filenames referenced in the Xcode workspace and the symbols defined in those files.
My problem is that our project is huge: if I generate a TAGS file using etags for the .h and .m files in our project's sub-directories, the result is over a gig in size and Emacs complains "TAGS file is large. Really open?", and if I say yes, then Emacs hangs and becomes essentially unusable. Of course, this is before I've even considered indexing tags for system libraries. I've also tried projectile, but unfortunately it's similarly unusable on a project of my size (on the order of a full minute to find a match).
It occurs to me that all the indexing information I really want is in the Xcode projects themselves, so if I had an Emacs package that could parse them and traverse their dependencies, that might be a start, but I'm not aware of any such package.
Any suggestions/solutions in this respect?
I've never found a single function quite as convenient as Xcode's "Open Quickly", but these days I use
helm-projectile-git-grep when I want to match on strings I know to be in the filenames, and
helm-git-grep for quick searches through the contents of the files themselves.
I've found that this gets me really close to what I wanted in my original question.

How to rename a file in IntelliJ without finding usages?

I am developing a Node.js project in IntelliJ.
The only way to rename files seems to be Shift+F6 which attempts to find all usages which takes too long (~30s - 1min).
Is there a way to simply rename the file without searching for usages?
This only happens when code is stored in Modules (which is necessary to be able to compact empty middle packages).
Best way I have found is to map ALT+SHIFT+F6 to Reveal in Finder. Then just press enter and type in new name.
It's good because its very similar to SHIFT+F6 rename refactor.
No.
IntelliJ must find the usages to rename them, otherwise you're just renaming the file, not refactoring. If you only want to rename the file, use the mv command from a terminal. You can also tell IntelliJ not to look in strings and text, which speeds things up somewhat, but is probably a bad idea in a javascript project (where almost everything is string or text).
I use rename a lot, and on my codebase, which is pretty big, it only takes a couple of seconds. Maybe intellij needs more memory to operate in, so you could try increasing that.
If You are doing it many times, You can create a custom scope for the refactoring:
There You can narrow the scope to few files/folders/modules etc. And for very narrow scope it will work as normal rename.

If I have multiple classes in one file, is there a tool to make them into separate files?

Some colleagues, now departed, had the habit of adding new classes within a related class file.
This makes refactoring painful.
Is there a tool, perhaps within XCode or AppCode or just a simple script, that will split up these monster files?
It appears there is a tool to help with this in AppCode, but it only semi-automates the process.
I'm using AppCode 2.0, I don't know if the same tool is available in AppCode 1.x.
To extract one class from a file to a new file, right-click the#interface or #implementation line and select Refactor > Move. Alternatively press F6 on that line. You can now enter a new file name, though you probably want to copy+paste the class name in here. At this point you can also select any defines you want to move.
I have done some work on a script to extract all classes in a file. I'd love to share this one day, when I get the chance to remove our clients code from the unit tests!
I don't think so there is any tool for this. However you can write your own osx application for doing the same.
The application will ask to browse the file, and it will search for #interface....#endand#implementation....~#end` and will create a file from this. If a single file contains two classes then it will result in for files (two headers and two implementation). Then the original file can be deleted manually or automatically.
I think this above task can be completed in few hours.
Here you can go for save the original file in a folder, just in case you want to rollback.

Avoiding issues when moving or duplicating a project folder in Labview

I have a Labview project containing several classes and a few VIs associated with each class.
The project and all the associated files are contained in a single directory.
When I duplicate (or even rename !) the project dir, I am able to load it but Labview warns me that several "Conflicts" exist. I wasn't able to resolve them by myself.
I understand that Labview can get confused if it loads a few identically-named VIs from another folder ; but why do problems appear even when renaming the folder ?
Isn't there a way to tell Labview to look first in the relative path and load in priority whatever it finds there, without looking elsewhere ?
Why is an operation that is so easy in text-based languages (recursive copy of a folder) so complicated and troublesome in Labview ?
I also tried duplicating the whole hierarchy through "File -> Save", but this also produced conflicts..
Renaming or copying a whole project usually work, since project's VIs are specified by paths relative to the project file.
However there are cases where other VIs referencing VIs inside the project folder. In this case you get conflicts, unless you save the project to another location using "Save as" dialog and specify "Duplicate .lvproj file and contents"
My solution is that I don't think there is a solution. I have the same problem and I have even talked to NI about it with no help.
I did find that, even when the list of conflicts is large, you only need to resolve a few conflicts before LabVIEW figures out the rest. Also don't panic if LabVIEW won't let you resolve a particular conflict. Just move on to the next conflict that you can resolve. As I said before, in time, LabVIEW will figure out the rest.