当在Vim中编写Java代码时,如何在编辑时直接显示代码输出。

huangapple 未分类评论44阅读模式
英文:

When coding java in Vim how can i show outout of code directly in in vim when editing

问题

以下是翻译好的内容:

在Vim中编辑Java代码时,假设我想要看到代码的输出。通常我会保存,然后回到命令提示符下编译和运行代码。

在编辑代码时,有没有办法让我在Vim中看到代码的输出?

Vim能否在不退出或输入许多命令的情况下自动保存并显示输出?

英文:

When editing a Java code in Vim assume I like to see the output of the code. normally I save and come to prompt and compile and run the code.

Is there any way, when editing the code I can see the output of the code in the vim itself?

Vim automatically saves and shows the output without exiting or typing many commands ?

答案1

得分: 0

你可以做的是创建一个映射,用于保存文件,然后使用 javac/java 进行编译和运行。当你想要测试你的代码时,你可以按下快捷键。

你在问题中描述的“在编辑(输入)时显示输出”,你是可以做到的,vim 有 TextChangedTextChangedI 事件,在触发这些事件时可以执行一些操作。然而,你可能不会希望这样做。因为在你的代码变得可以编译之前,每次你键入一个键,你都会看到一个编译错误。

甚至 IntelliJ 也不支持在你编辑 Java 文件时自动运行的功能。

英文:

What you can do is creating a mapping, to save the file, compile and run with javac/java. When you want to test your codes, you press the shortcut.

What you described in your question, "showing the output as you editing(typing)", You can do it, vim hasTextChanged and TextChangedI events, you can do something when the events are triggered. However, you won't want it. Because, before your codes become compile-ready, every time you type a key, you will see a compilation error.

Even intellij doesn't support a feature of auto-run a java file as you are editing it.

huangapple
  • 本文由 发表于 2020年4月7日 10:25:50
  • 转载请务必保留本文链接:https://java.coder-hub.com/61071856.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定