Chetan Jain
Chetan Jain

Reputation: 241

Could i write an extension to open an editor to side in Vs code

I would like to make a vs code extension for that so a user presses a key combination than a text editor will open to the side where he could enter lines of text then whenever the text changes I would receive events with the changed text. Could you suggest to me how to open the editor if is it possible? Thank you for taking the time to read the question. Hope you have a great day ahead.

Upvotes: 1

Views: 466

Answers (2)

Ilka
Ilka

Reputation: 90

I have the same problem and this answer helped me. My resulting code:

vscode.commands.executeCommand(
    'vscode.openWith',
    vscode.Uri.parse('file:///path/to/my/file'),
    'default',
    vscode.ViewColumn.Beside
)

Upvotes: 0

boocs
boocs

Reputation: 599

You can use showTextDocument and use ViewColumn.Beside to open the editor to the side of the currently active one:

https://code.visualstudio.com/api/references/vscode-api#window

You can listen for text doc changes with the onDidChangeTextDocument event:

https://code.visualstudio.com/api/references/vscode-api#workspace

Here's info on creating a command to open the preview window.

https://code.visualstudio.com/api/references/vscode-api#commands

Upvotes: 2

Related Questions