Search code examples
javaeditorresetjava-9jshell

How to reset to default editor in jshell, in current sessoin?


In current session, I had set an external editor which I want to revert to default one. So, how to reset to default editor in jshell, in current sessoin?

EDIT:

I searched on net and found this link cr.openjdk.java.net/~rfield/tutorial/JShellTutorial.html which didn't help. I tried with DEFAULT as an option(guessing on the lines of default startup script), didn't help.


Solution

  • As @Andreas said. It's written in the documentation.

    Find below working steps (assuming you did not use an environment variable to change the default editor)

    • set an alternative editor

      jshell> /set editor your-editor
      |  Editor set to: your-editor
      
    • enter some snippet (only for demonstration)

      jshell> String foo = "foobar"
      foo ==> "foobar"
      
    • edit the snippet

      jshell> /edit foo
      

      this opens your-editor with the snippet String foo = "foobar";

    • set the editor back to default

      jshell> /set editor -default
      |  Editor set to: -default
      
    • edit the snippet

      jshell> /edit foo
      

      this opens JShell Edit Pad with the snippet String foo = "foobar";