De-Indenting a Line After You Have Typed It

In my custom language, I want to de-indent a line as follows

if a == 1 then
   b = 2
   end <hit enter here>

it should be

if a == 1 then
   b = 2

One idea I had was to invoke the formatter for the current line when the enter key was pressed. I haven't figured out how to do that exactly yet.

Any advise?

1 comment
Comment actions Permalink

Hi Jon,

You can provide your own implementation of com.intellij.codeInsight.editorActions.enter.EnterHandlerDelegate, register it at your plugin.xml like

<enterHandlerDelegate implementation="com.yourpackage.YourImplementationClassName"/>

Then you can define correct indent for the line with 'end' (you can do we either manually on text level or call com.intellij.psi.codeStyle.CodeStyleManager.adjustLineIndent())



Please sign in to leave a comment.