gpt4 book ai didi

eclipse - 在eclipse中存储代码片段

转载 作者:行者123 更新时间:2023-12-02 11:42:54 25 4
gpt4 key购买 nike

在使用 vi 和 gvim 20 年后,我最近半转向 Eclipse。我怀念 gvim 的一件事是,我可以将一堆不同的代码片段剪切到命名缓冲区中,并在执行诸如重复常见习惯用法之类的操作时随意粘贴它们。例如,我会拥有它,这样 "ap 就会粘贴

DatabaseHandle handle = null;
try
{
handle = DatabaseConnectionPool.newHandle();

然后“bp将粘贴

  handle.commit();
}
finally
{
handle.rollback();
DatabaseConnectionPool.returnHandle(handle);
}

我可以在一天内一遍又一遍地重复这两个内容。在回答另一个问题时,有人提到您可以在 Eclipse 中“管理代码片段”,但没有提及如何操作。所以现在我问:如何在 Eclipse 中管理代码片段?

最佳答案

您可能希望将这两个片段存储到 code template 中,如 this tutorial 中所述.

并且不要忘记快速执行scrapbook中任何类型的java代码片段的可能性。 (不完全是你想要的,但它有时会派上用场)

Newtopian添加(在评论中)

In fact templates become much more powerful by adding variables and tabstops within, so your example above would become dbHandle ctrl+space. It would copy snippets from both parts and place your cursor right in the middle.

关于eclipse - 在eclipse中存储代码片段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/237987/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com