# open-editor

> Open files in your editor at a specific line and column

Latest version **6.0.0** (published 2025-11-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install open-editor
pnpm add open-editor
yarn add open-editor
bun add open-editor
```

## Health

**Score 60/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 6.0.0 |
| Published | 2025-11-23 |
| First published | 2016-09-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=20 |
| Dependencies | 4 |
| Unpacked size | 8.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 212 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | open, editor, launch, files, file, line, column, position, path, filepath, editors, start, app, sublime, atom, vscode, webstorm, textmate, vim, neovim, intellij, emacs, nano |

## Links

- npm: https://www.npmjs.com/package/open-editor
- Repository: https://github.com/sindresorhus/open-editor
- Homepage: https://github.com/sindresorhus/open-editor#readme
- Issues: https://github.com/sindresorhus/open-editor/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/open-editor

## Dependencies (4)

- [open](https://npm.io/package/open.md) ^11.0.0
- [execa](https://npm.io/package/execa.md) ^9.6.0
- [env-editor](https://npm.io/package/env-editor.md) ^1.3.0
- [line-column-path](https://npm.io/package/line-column-path.md) ^4.0.0

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 6.0.0 (latest) — 2025-11-23
- 5.1.0 — 2024-12-22
- 5.0.0 — 2024-07-14
- 4.1.1 — 2023-08-28
- 4.1.0 — 2023-08-05
- 4.0.0 — 2021-11-03
- 3.0.0 — 2020-12-20
- 2.0.1 — 2019-04-24
- 2.0.0 — 2019-04-23
- 1.2.0 — 2017-06-16
- 1.1.0 — 2017-05-07
- 1.0.1 — 2017-05-04
- 1.0.0 — 2016-09-23

## README

# open-editor

> Open files in your editor at a specific line and column

Supports any editor, but only the following editors will open at a specific line and column:

- Sublime Text
- Atom
- Zed
- Visual Studio Code
- VSCodium
- WebStorm*
- TextMate
- Vim
- NeoVim
- IntelliJ IDEA*

*\*Doesn't support column.*

## Install

```sh
npm install open-editor
```

## Usage

```js
import openEditor from 'open-editor';

openEditor([
	{
		file: 'readme.md',
		line: 10,
		column: 2,
	}
]);

openEditor([
	'unicorn.js:5:3',
]);
```

## API

### openEditor(files, options?)

Open the given files in the user's editor at specific line and column if supported by the editor. It does not wait for the editor to start or quit unless you specify `wait: true` in the options.

#### files

Type: `Array<string | URL | object>`

Items should be in the format `foo.js:1:5` or `{file: 'foo.js', line: 1: column: 5}`.

#### options

Type: `object`

##### wait

Type: `boolean`\
Default: `false`

Wait until the editor is closed.

```js
import openEditor from 'open-editor';

await openEditor(['unicorn.js:5:3'], {wait: true});

console.log('File was closed');
```

##### editor

Type: `string`\
Default: [Auto-detected](https://github.com/sindresorhus/env-editor)

The name, command, or binary path of the editor.

**Only use this option if you really have to.** Can be useful if you want to force a specific editor or implement your own auto-detection.

### getEditorInfo(files, options?)

Same as `openEditor()`, but returns an object with the binary name, arguments, and a flag indicating whether the editor runs in the terminal.

Example: `{binary: 'subl', arguments: ['foo.js:1:5'], isTerminalEditor: false}`

Can be useful if you want to handle opening the files yourself.

```js
import {getEditorInfo} from 'open-editor';

getEditorInfo([
	{
		file: 'foo.js',
		line: 1,
		column: 5,
	}
]);
//=> {binary: 'subl', arguments: ['foo.js:1:5'], isTerminalEditor: false}
```

## Related

- [open-editor-cli](https://github.com/sindresorhus/open-editor-cli) - CLI for this module
- [open](https://github.com/sindresorhus/open) - Open stuff like URLs, files, executables

---
_Source: https://npm.io/package/open-editor · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
