Storing code snippets in eclipse

前端 未结 7 1497
你的背包
你的背包 2020-11-29 17:19

I\'m a recent semi-convert to Eclipse after 20 years of using vi and gvim. One of the things I miss about gvim is that I could cut a bunch of different snippets of code int

相关标签:
7条回答
  • 2020-11-29 17:31

    I ran into the Snip2Code plugin recently. It did the job, and I can collect and search snippets in a quick way.

    0 讨论(0)
  • 2020-11-29 17:39

    I have used snippets in some IDEs, like Dreamweaver and Homesite, an old Coldfusion IDE. I also use a lot of snippets in MySQL Workbench - where i type a lot of SQL, very handy there.

    I am now using Eclipse Java EE IDE for Web Developers Version Indigo Release and found the snippets panel in Window|Show View|Other...|General|Snippets. I was able to manipulate it and figure out how to add the code I wanted as snippets and how to use it efficiently.

    0 讨论(0)
  • 2020-11-29 17:40

    You might want to store those two snippets into a code template, as explained in this tutorial.

    And do not forget about the possibility to quickly execute any kind of java code snippets in a scrapbook (not exactly what you want, but it can come in handy at times)

    Newtopian adds (in the comments)

    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.

    0 讨论(0)
  • 2020-11-29 17:42

    Well a picture worths a thousand words, what about this one?

    0 讨论(0)
  • 2020-11-29 17:42

    The question is old but the link of the answere is older ;)

    Here is a nice tutorial: http://www.dansshorts.com/post/creating-snippets-in-eclipse

    0 讨论(0)
  • 2020-11-29 17:44

    Use Eclipse Snipmatch (Part of Eclipse for Java Developers Package).

    • Works very well for Java code snippets but also works for any other language like HTML, ABABP, PHP etc.
    • You can convert any code fragment from your editor directly to a code template. Highlight the code you'd like to convert to a snippet, context menu "create snippet", complete the form and done.
    • snippets can be shared via Git repositories with your team members

    Manual: https://www.eclipse.org/recommenders/manual/#snipmatch

    Installation: https://marketplace.eclipse.org/content/snipmatch

    0 讨论(0)
提交回复
热议问题