How to run a file in a new window in IntelliJ IDEA - intellij-idea

I need to run the java file in a new window
IntelliJ IDEA. If I run this file with the project open, the file opens in it, and not in a new window
I tried to open by opening the folder with the file in IntelliJ IDEA, but this only works if some project is already opened in IntelliJ IDEA, otherwise only the project opens, but the file does not.
"path to idea" "path to project" && "path to idea" "path to java file"

Related

Intellij Plugin Develop: How to properly open a file after creation and loaded by IDE

I want to create a java file and open it immediately. I write:
PsiFile file = PsiFileFactory.getInstance(project).createFileFromText(fileName, language, fileContent);
directory.add(file);
FileEditorManager.getInstance(project).openFile(file.getVirtualFile(), true, true);
It works but the opened file does not have any highlights, and the icon is gray. It seems that the IDE has not finished loading it.
So how to open file after IDE loaded it?
I try use CodeStyleManager.getInstance(project).reformat(file); to highlight the file, it works.
But the icon is still gray. And this file cannot use the "Select open file" button to navigate to the target file tree node.
I plan to use JavaDirectoryService.getInstance().createClass(dir, className, true); but I'm not sure how to use it correctly to open the created file ?

IntellliJ IDEA LightEdit mode won't open file if IDE already running

When I use the idea command line tool to open a file in LightEdit mode
$ idea myfile.txt
and IDEA is already open in project mode it will not open file file. IDEA gets focus but the file does not open.
However, when I used the idea command line to open a file in LightEdit mode and IDEA is not already open, it works as expected.
If you use the Create Command-line launcher option to recreate the idea launcher file it will start working as expected.

How to reformat all the open files in IntelliJ

Is there any shortcut to reformat the code in all the open files in IntelliJ? I'm specifically looking for a way to reformat all the open files inside editor and not all the files in project.
The closest that I could recommend is to select the root folder from the project explorer and press alt+command+L(MAC OS). Reformat Code window pops up. In the pop-up, select the scope as Open files and Click run. It formats all the open files
Intellij Documentation -->https://www.jetbrains.com/help/idea/reformat-and-rearrange-code.html#reformat_module_directory

Force PhpStorm to recognize a project file

I have an annoying scenario in PhpStorm;
When I open a file by invoking the PhpStorm launcher with a relative file path as the only argument (phpstorm src/ZumbaController.php) the application will launch, but as the file is saved a prompt appears;
open a file from the terminal
dreaded confirm write-file dialog
Opening the file by the full, absolute path does not help. Having the current working directory of the shell be the real path of the project does not help either (opening from the real project directory). Is there a way to instruct PhpStorm that this file belongs to the currently-open project?
(I considered posting on superuser, but this is more of a programers-only problem)

How to open file with IntelliJ IDEA in new tab with command line?

How can I specify the file to open in new tab with IntelliJ IDEA via command line?
If I run in command line:
idea d:\Dropbox\Dropbox\featurea\featurea-common\src\com\featurea\common\util\FileManager.java
I get "No project found to open file in" error
Open file in new tab with opened project also fails.
Is there any way to manage IntelliJ IDEA to behave as I want?
Thanks.
You can't open individual files in the IDE from the command line when there is no open project and the IDE is not already running.
You can pass the project directory as an argument to open the project first, then you will be able to open individual files.