UNPKG

1.74 kBMarkdownView Raw
1# open-editor [![Build Status](https://travis-ci.org/sindresorhus/open-editor.svg?branch=master)](https://travis-ci.org/sindresorhus/open-editor)
2
3> Open files in your editor at a specific line and column
4
5Supports any editor, but only the following editors will open at a specific line and column:
6
7- Sublime Text
8- Atom
9- Visual Studio Code
10- WebStorm*
11- TextMate*
12
13*\*Doesn't support column.*
14
15
16## Install
17
18```
19$ npm install --save open-editor
20```
21
22
23## Usage
24
25```js
26const openEditor = require('open-editor');
27
28openEditor([
29 'unicorn.js:5:3',
30 {
31 file: 'readme.md',
32 line: 10,
33 column: 2
34 }
35]);
36```
37
38
39## API
40
41### openEditor(files, [options])
42
43Open 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.
44
45#### files
46
47Type: `Array<string|Object>`
48
49Items should be in the format `foo.js:1:5` or `{file: 'foo.js', line: 1: column: 5}`.
50
51#### options
52
53Type: `Object`
54
55##### editor
56
57Type: `string`<br>
58Default: [Auto-detected](https://github.com/sindresorhus/env-editor)
59
60Name, command, or binary path of the editor. Only use this option if you really have to.
61
62Can be useful if you want to force a specific editor or implement your own auto-detection.
63
64### openEditor.make(files, [options])
65
66Same as `openEditor()`, but returns an object with the binary name and arguments.
67
68Example: `{bin: 'subl', args: ['foo.js:1:5']}`
69
70Can be useful if you want to handle opening the files yourself.
71
72
73## Related
74
75- [open-editor-cli](https://github.com/sindresorhus/open-editor-cli) - CLI for this module
76- [opn](https://github.com/sindresorhus/opn) - Opens stuff like websites, files, executables
77
78
79## License
80
81MIT © [Sindre Sorhus](https://sindresorhus.com)