fzf: score certain filetypes higher - fzf

I have something like the following command:
ag -g "" | fzf
So, the Silver Searcher gives me a list of files and fzf filters them. I have .java and .ts files (among others) in the project, but most of the time I only want to jump to the .ts files. I don't really want to lose the possibility to jump to .java files, so filtering for "*.ts" wouldn't suit my needs. I just want the .ts files to come up first.
I would like to see the .ts files coming before the .java files. isn't there an option for fzf to score some filetype higher?

Related

How to navigate to file in WebStorm if file belongs to excluded folder?

I've excluded vendor folder from indexing.
I can navigate to file if it outside of vendor folder with Ctrl + Shift + N but if a file inside the one WebStorm can't find it.
You can try to do an "All" search with double shift. It should appear there if you have ever visited the file. If you haven't opened the file, most probably it will not appear there.
The reason for excluding files from indexing is mainly the good performance and marking directories that contain for example build artifacts or libraries to not add noise to your search results. That's why you will not see them.

File-based, not Folder-based, Projects in Atom?

I'm trying to switch to Atom as my programming editor so that I can gain handy features like linting for Perl, JavaScript, etc. However, over the last two decades, I've used a string of editors (UltraEdit, jEdit, BBEdit) that allowed me to add individual files from different folders into projects. My main coding project actually spans several remote SFTP servers and the "folders" in my BBEdit project do not necessarily correspond to any file structure on disk.
I cannot seem to figure out how to set up a project in this manner in Atom (or similar editors such as Brackets). Is there a way to configure Atom and its extensions to produce a result similar to an UltraEdit/jEdit/BBEdit/Komodo project? I thought about creating a new project directory and symlinking to the real files, but that seems like a hack at best.
I belive its File > Open Project or something like that. I personally like Sublime Text 3 but Atom and Sublime are the same.
The best solution I have found so far would be to install opened-files package. By default it persists all files you have opened (even after you close them) until you close atom editor. I don't think it would work well for bigger projects as it lists all the files under one tab in tree view.
If you want to persist open files you might want to use project-manager package. To keep files listed under 'Opened files' tab after you close them (and atom), you need to press bookmark icon next to tab name. Once you add the project it auto-saves file structure when you close atom. To add project to project-manager write project-manager save in command palette. To list all projects from project manager press shift-alt-P.

How do I use the folder path that a user selects and use that path when they download files?

I'm in the process of creating a launcher for a game with Visual Basic and I have pretty much everything done except many people may have files in different drives. So, I want them to select a file path then when they have selected that path I want the download button to download the files that the need downloaded to the selected directory. I was thinking that the beginning of the code would be something like this:
Form2.TextBox1.Text
and then something else after that in the buttons code.
I hope I'm being specific enough.
P.S. The reason why this is an issue is because if I use System.Diagnostic.Process.Start("C:\Program Files (x86)\[remaining folderpath here]") to launch the .exe then the program will only look for the files in that directory even though some people may have the files in their D: drives, etc. And, I have a FolderDialog setup and working.

Ignore a folder in search results

I'm searching for a string and getting matches in a source folder, and a build folder (file in source gets copied to build during build).
I do not need the build folder result.
Vim has wildignore which helps filter out results.
Is there something similar in intelij?
Mark your build folder as excluded:
File > Project Structure > Modules > Sources > Mark as Excluded (red icon)
You can also just right click on your folder and select Mark Directory As > Excluded.
Excluded folders (shown as rootExcluded) are ones that IntelliJ IDEA "partially ignores". Very limited coding assistance is provided for files in excluded folders. Classes contained in excluded folders don't appear in code completion suggestion lists, references to such classes are shown in the editor as unresolved. When searching, IntelliJ IDEA doesn't look in excluded folders, etc.
Source
Note: See the answer by Nader Hadji Ghanbari for another approach using Scopes.
Short Answer
By defining a Scope when searching, you can include/exclude arbitrary files/folders from that scope.
Detailed Answer
One way to achieve your requirement (excluding files and folders from a search) is to define a custom scope. This is specifically useful because sometimes you just want to exclude a folder from your search and not from the whole project.
Follow these steps:
Edit -> Find -> Find in path or press Ctrl+Shift+F.
Choose Custom in the Scope section and then choose <unknown scope>
Now click on the + button to add a new local custom scope
Give the scope a name and save it.
Now you can include and exclude directories from this scope. You can first add everything by choosing the include recursively and then exclude one by one by choosing exclude or exclude recursively.
Note that you can even include or exclude libraries your project is dependent on.
When searching you can choose the effective scope by in Scope section in Find in Path dialog.
More info
You can check the JetBrains docs on Scopes for more info. Scopes can be used not only when searching but also in a bunch of other use cases in IntelliJ IDEA.
Patterns
You can use Patterns to define a scope which makes them even more powerful and future proof.
using patterns is another way to exclude files and folders. For instance
file:src/main/java//*&&!file:src/main/java/my//* will exclude all files in my folder.
In Intellij 15, to exclude a folder just do this:
in the Project window, select the folder then right click and choose "Mark Directory As" > "Excluded"
IntelliJ IDEA 2021.3.3 (Ultimate Edition)
In my case, all the generated files in .tox and _build kept showing up in my Find results. It may be a blunt instrument but I added these two folder types to the Preferences -> Editor -> File Types -> Ignored Files and Folders: .tox, _build. For whatever reason, adding _build will not be accepted as part of the ignored set.
Caveat, you will not see these files and folders in your Project navigator. However, it’s a small price to pay for not having them show up consistently in my search results.
A number of answers work well for older versions of IntelliJ, but in 2020.2, and possibly other recent versions, I keep seeing excluded folders in my search results. In my case: node_modules.
I found something that does work, though. For javascript projects, at least. There might be something similar available for other languages.
First, of course, exclude the directory from your project.
Hopefully this works, but if it doesn't, and you're using Javascript, continue:
Go to Settings -> Languages & Frameworks -> Javascript -> Libraries
There, uncheck all the directories you don't want included in your search.
Whether this is a good idea remains to be seen; IntelliJ doesn't merely exclude them from your search, but from all its code parsing, which means it might not recognise imports from that directory either. For me it seems to work fine at the moment, but I give no guarantees. Try it, but remember how to revert this.
It's an ugly work around. IntelliJ clearly needs a better way to exclude directories from searches.
As some have mentioned, simply setting a folder to 'Excluded' doesn't work in many versions. A combination of the following does for me:
Set the offending folder to 'Excluded' as suggested.
Use the pre-defined Scope 'Project Files'
Profit
Excluding files and folders from projects
Article last modified: 08 June 2020
Mark a file as plain text
In the Project tool window, select the desired file.
From the context menu of the selection, choose Mark as plain text:
Exclude files and folders by name patterns
In the Settings/Preferences dialog Ctrl+Alt+S, click Directories .
In the Exclude files field, type the masks that define the names of files and folders to be excluded, for example, *.min.js or lib. Use semicolons as separators.
If the name of a file matches any of these patterns, the file is treated as excluded.
If the name of a folder matches a pattern, all the files in this folder and in its subfolders are excluded.
Source: https://www.jetbrains.com/help/phpstorm/excluding-files-from-project.html
This one the only thing that works for me on IntelliJ 2022.3.1, even when marking directory as excluded didn't work (it only change the icon as red, but still shows up).
File > Preferences > Editor > Ignored Files and Folders
I can ignore the generated bla.html with this.
If you are searching for usages, open the "Find Usages Settings..." , by default Ctrl+Alt+Shift+F7, to narrow down the scope from "All files" to "Project files".

Is it possible to exclude a file from the content root in IntelliJ?

I want to exclude individual .java files from a Content Root in IntelliJ. The documentation on "Excluding Files from Project" suggests that this is not possible (it explicitly says This action is not applicable to Java files and binaries.)
Being incredulous to such a limitation, I have tried editing my .iml file, optimistically inserting XML elements such as <excludeFile> under the <content> element, but nothing seems to take.
Does anyone know a way to do this (documented or otherwise)? Or have any clue why this feature is not supported? By comparison, Eclipse allows for an arbitrary including pattern for a <classpathentry> element in its .classpath file.
You can exclude files from compilation and classpath. As far as I understand it will have the same effect as manipulating with <classpathentry> in Eclipse.
To exclude files/folders by pattern and globally use Ignore files and folders option in the File Types dialog. This way the files will be completely ignored and not visible in the Project View, but it's probably not what you want.