Automatically recognize the editor by running processes and open the specified file in it.
npm install launch-ideAutomatically recognize the editor by running processes and open the specified file in it. It is compatible in Windows, MacOS and Linux.
There are already some tools to open the file in the editor, but launch-ide has the following advantages:
- Automatically recognize the editor by running processes, you don't need to configure the editor path.
- Launch the ide by the executable file of the editor, so you don't need to install the command line tools of the editor such as code.
- Support for more editors such as VSCode, Cursor, Windsurf, WebStorm, etc.
- Compatible with platforms such as Windows, MacOS, and Linux.
- Compatible for Chinese characters in the file path.
``bash`
npm i launch-ide
`ts
import { launchIDE } from 'launch-ide';
// Open the file in the current editor and position the cursor at line 10 and column 20
launchIDE({ file: '/Users/zh-lx/Desktop/test.ts', line: 10, column: 20 });
// Open the file with more options
launchIDE({
file: '/Users/zh-lx/Desktop/test.ts', // required: the file path to open
line: 10, // optional: the line number to position the cursor at
column: 20, // optional: the column number to position the cursor at
editor: 'code', // optional: specify the editor with IDE encoding name
});
`
`ts
interface LaunchIDEParams {
/**
* @required
* @type: string
* @description: the file path to open
*/
file: string;
/**
* @optional
* @type: number
* @description: the line number to position the cursor at
*/
line?: number;
/**
* @optional
* @type: number
* @description: the column number to position the cursor at
*/
column?: number;
/**
* @optional
* @type: string
* @description: specify the editor with IDE encoding name
*/
editor?: string;
/**
* @optional
* @type: string
* @description: when you use the editor outside the supported list, you can specify the format of the file to open
* @default '{file}:{line}:{column}'
*/
format?: string;
/**
* @optional
* @type: string
* @description: reuse or open a new window to open the file
* @default 'auto'
*/
method?: 'reuse' | 'new' | 'auto';
/**
* @optional
* @type: function
* @description: callback function when an error occurs
*/
onError?: (file: string, error: string) => void;
/**
* @optional
* @type: string
* @description: Whether to guess the editor by the process id. When you use pid, the accuracy of the editor is higher, but the performance is lower.
* @default false
*/
usePid?: boolean;
/**
* @optional
* @type: string
* @description: The ways to launch the editor. exec: opening editor using the executable path; open: opening editor using the open command. Only effective on MacOS and these editors: code/cursor/windsurf/qoder/comate/trae/codebuddy/antigravity/kiro/codium
* @default exec
*/
type?: 'exec' | 'open';
}
`
| IDE | IDE Encoding Name | MacOS | Windows | Linux |
|---|---|---|---|---|
| Visual Studio Code | code | ā | ā | ā |
| Cursor | cursor | ā | ā | ā |
| Windsurf | windsurf | ā | ā | ā |
| Trae | trae | ā | ā | ā |
| Qoder | qoder | ā | ā | ā |
| CodeBuddy | codebuddy | ā | ā | ā |
| Antigravity | antigravity | ā | ā | ā |
| comate | comate | ā | ā | ā |
| VSCode Insiders | code-insiders | ā | ā | ā |
| VSCodium | codium | ā | ā | ā |
| WebStorm | webstorm | ā | ā | ā |
| Atom | atom | ā | ā | ā |
| HBuilderX | hbuilder | ā | ā | |
| PhpStorm | phpstorm | ā | ā | ā |
| Pycharm | pycharm | ā | ā | ā |
| IntelliJ IDEA | idea | ā | ā | ā |
| Brackets | brackets | ā | ā | ā |
| Appcode | appcode | ā | ||
| Atom Beta | atom-beta | ā | ||
| Clion | clion | ā | ā | |
| Rider | rider | ā | ā | ā |
| Rubymine | rubymine | ā | ā | ā |
| Emacs | emacs | ā | ||
| Sublime Text | sublime | ā | ā | ā |
| Notepad++ | notepad | ā | ||
| Vim | vim | ā | ||
| Zed | zed | ā | ā |
?On macOS, some editors support opening with open. Taking VSCode as an example: open "vscode://file/xxx/yy/main.jsx:10:20". This method opens the editor quickly and provides a good experience, so it is strongly recommended that users set type: 'open' when using following editors:
- vscode
- cursor
- windsurf
- antigravity
- qoder (Not CN version)
- comate (Not CN version)
- trae (Not CN version)
- codebuddy (Not CN version)
There are two ways to specify the editor:
1. Specify the editor with IDE encoding name in launchIDE.
`ts`
launchIDE({
file: '/Users/zh-lx/Desktop/test.ts',
line: 10,
column: 20,
editor: 'cursor'
});
2. Specify the editor with IDE encoding name in .env.local file by CODE_EDITOR.
`bash``
CODE_EDITOR=cursor
If you use the editor outside the supported list, you can specify the editor by its executable file path, please refer to Other Editor.