Opening Files from Command Line
You can open a file for editing in IntelliJ IDEA from the command line, with the caret positioned at the specified code line.
- In the command line, run the following command:
<IntelliJ IDEA> path1 --line <number> path2
The command options are as follows:
| || The platform-dependent IntelliJ IDEA launcher. |
On macOS and Linux, it is recommended to use the command line launcher created during the IntelliJ IDEA installation, or create one manually by selecting on the IntelliJ IDEA main menu. Refer to Working with IntelliJ IDEA Features from Command Line for details.
| ||The path to the project that contains the desired file.|
| ||The number of the line, where the caret should rest.|
| ||The path to the file to be opened.|
<IDE_HOME>\bin\idea.exe path1 --line <number> path2
<IDE_HOME>\bin\idea.exe C:\MyProject\ --line 3 C:\MyProject\scripts\numbers.js
IntelliJ\ IDEA.app/Contents/MacOS/idea path1 --line <number> path2
IntelliJ\ IDEA.app/Contents/MacOS/idea ~/MyProject/ --line 3 ~/MyProject/scripts/numbers.js
<IDE_HOME>/bin/idea.sh path1 --line <number> path2
<IDE_HOME>/bin/idea.sh ~/MyProject/ --line 3 ~/MyProject/scripts/numbers.js