Toby Toby - 1 year ago 92
Java Question

Read and Write to current editor pane from IntelliJ plugin (plugin-dev)

Is it possible to get the current editor pane and edit the contents from an IntelliJ (IDEA) plugin?

I'd like to for example, select some text in the current editor and overwrite it with my own.

I've got this far;

Editor editor = FileEditorManager.getInstance(event.getProject()).getSelectedTextEditor();
VisualPosition position = editor.getCaretModel().getVisualPosition();
Document document = editor.getDocument();
document.insertString(position.column, Character.toString(text.charAt(offset)));

coming in from the

but it doesn't update the editor panel.

Any pointers much appreciated.

Answer Source

Please see for some general guidance.

It would be easier to answer your question if you specify your exact usecase.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download