javamacoseditorjava-9jshell

How to set sublime as an external editor for jshell?


According to the jshell documentation:

An alternative to editing at the command prompt is to use an external editor. This editor can be used to edit and create snippets, and is especially helpful for multiline snippets. You can configure JShell to use the editor of your choice.

So to implement this, i use the following commands:

jshell> /set editor sublime
|  Editor set to: sublime

And then, i tried to edit a snippet as follows:

jshell> /edit printName
|  Edit Error: process IO failure: Cannot run program "subllime": error=2, No such file or directory

But, i got the above error. So is it the right way to set editor or something else is required? I also tried to set Microsoft Word as the editor and specified the exact application path from the Application folder of Mac as follows:

jshell> /set editor /Users/karan.verma/Applications/Microsoft Word.app
|  Editor set to: /Users/karan.verma/Applications/Microsoft Word.app

Even, when i set the editor as "atom", i got the same results:

jshell> /set editor atom
|  Editor set to: atom

But still it shows the same error. Any help?


Solution

  • Mightn't have worked for the OP. But worked for me. So, posting it here hoping it helps someone.

    If you can type subl on a terminal and if Sublime Text opens (means subl is in PATH), try:

    /set editor subl -w
    

    If Sublime Text doesn't open on typing subl on terminal, but running "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" does open Sublime Text (means subl is not in PATH), try:

    /set editor "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" -w
    

    -w flag is to wait for the files to be closed in Sublime Text before returning.