根据 jshell 文档:
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.
因此,为了实现这一点,我使用了以下命令:
jshell> /set editor sublime
| Editor set to: sublime
然后,我尝试按如下方式编辑片段:
jshell> /edit printName
| Edit Error: process IO failure: Cannot run program "subllime": error=2, No such file or directory
但是,我得到了上面的错误。 那么它是设置编辑器的正确方法还是需要其他东西? 我还尝试将 Microsoft Word 设置为编辑器,并从 Mac 的应用程序文件夹中指定确切的应用程序路径,如下所示:
jshell> /set editor /Users/karan.verma/Applications/Microsoft Word.app
| Editor set to: /Users/karan.verma/Applications/Microsoft Word.app
甚至,当我将编辑器设置为“atom”时,我得到了相同的结果:
jshell> /set editor atom
| Editor set to: atom
但它仍然显示相同的错误。有帮助吗?
最佳答案
可能不适用于 OP。但为我工作。所以,将其张贴在这里,希望对某人有所帮助。
如果您可以在终端上键入 subl
并且 Sublime Text 打开(意味着 subl
在 PATH
中),请尝试:
/set editor subl -w
如果在终端上输入 subl
时 Sublime Text 没有打开,但是运行 "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"
可以打开 Sublime Text(意味着 subl
不在 PATH
中),尝试:
/set editor "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" -w
-w
标志是等待文件在Sublime Text中关闭后再返回。
关于java - 如何将sublime设置为jshell的外部编辑器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47866775/