Plugin Development: access selected Code Permanently deleted user Created October 02, 2014 13:03 Hey,I want that Code, selected in the editor, appears in my plugin View. How can I programmatically access my selected Code/Area?
There's a 'getSelectedText' method in SelectionModel interface. SelectionModel instance is available from Editor instance.
thank you very much.
How do you get the current editor from within the action?
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.