简体   繁体   English

如何将sublime设置为jshell的外部编辑器?

[英]How to set sublime as an external editor for jshell?

According to the jshell documentation:根据 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 以使用您选择的编辑器。

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:我还尝试将 Microsoft Word 设置为编辑器,并从 Mac 的应用程序文件夹中指定确切的应用程序路径,如下所示:

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:甚至,当我将编辑器设置为“atom”时,我得到了相同的结果:

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

But still it shows the same error.但它仍然显示相同的错误。 Any help?有什么帮助吗?

Mightn't have worked for the OP. 可能没有为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: 如果你可以在终端上键入subl并且如果Sublime Text打开(意味着sublPATH ),请尝试:

/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: 如果在终端上键入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 flag is to wait for the files to be closed in Sublime Text before returning. -w标志是在返回之前等待Sublime Text中的文件关闭。

It worked for me by supplying the full path to the sublime executable. 它通过提供sublime可执行文件的完整路径为我工作。 Eg on Windows. 例如在Windows上。

jshell> /set editor c:\\sublime3\\sublime_text.exe

您可以通过JSHELLEDITOR用户/系统变量指定jshell编辑器

In Windows set full path :
   jshell> /set editor C:\Program Files\Notepad++\notepad++.exe
Please do not include inverted commas(" ") in path
In MacOs use inverted commas with path.

Even i faced same problem as i was giving command 即使我遇到同样的问题,因为我正在给予命令

jshell > /set editor "/Applications/Sublime Text.app" jshell> / set editor“/ Applications / Sublime Text.app”

but what's missing is the exact path to bin directory in content folder of sublime. 但缺少的是sublime内容文件夹中bin目录的确切路径。

Solution: 解:

jshell > /set editor "/Applications/SublimeText.app/Contents/SharedSupport/bin/subl" jshell> / set editor“/Applications/SublimeText.app/Contents/SharedSupport/bin/subl”

Try this it will work 100%. 试试这个它将100%工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM