Plugin Development: access selected Code

Hey,
I want that Code, selected in the editor, appears in my plugin View. How can I programmatically access my selected Code/Area?

4 comments
Comment actions Permalink

There's a 'getSelectedText' method in SelectionModel interface. SelectionModel instance is available from Editor instance.

0
Comment actions Permalink

thank you very much.

0
Comment actions Permalink

How do you get the current editor from within the action?

0
Comment actions Permalink

CommonDataKeys.EDITOR.get(dataContext)

You can also extend com.intellij.openapi.editor.actionSystem.EditorAction, where this logic is implemented already. Check existing actions in intellij-community extending EditorAction for examples.

0

Please sign in to leave a comment.