Questions tagged [code-templates]

(Code) templates are a structured description of coding patterns that reoccur in source code. They are typically supported within IDEs to fill in commonly used source patterns.

Code templates are typically used within IDEs (or advanced text editors) in order to automatically generate content on behalf of the user.

A typical use case would be to have the IDE/editor automatically insert various elements when creating a new source code file (for example using a "user provided" copy right header).

Details depend on the underlying tool, example links:

96 questions
56
votes
4 answers

Creating new live-templates with import statements in IntelliJ IDEA

Here is the Eclipse template that I want to port: ${:import(org.apache.log4j.Logger)} private static final Logger LOG = Logger.getLogger(${enclosing_type}.class); My current version in IDEA is as follows: private static final Logger LOG =…
Philipp Claßen
  • 41,306
  • 31
  • 146
  • 239
40
votes
4 answers

How to set the Eclipse date variable format?

How can I set the format for the ${date} variable which can be used in Eclipse templates?
desolat
  • 4,123
  • 6
  • 36
  • 47
28
votes
2 answers

How can we write our own code template file in IntelliJ IDEA

I need to create a sample code template in my IntelliJ IDEA project so that everybody in the team can also kind of import it in their IDEs and use it. I am able to do it on my own machine by changing the "class" template myself, but i just don't…
ashish
  • 303
  • 1
  • 3
  • 7
22
votes
3 answers

Fast implement wrapping (delegate methods) in Eclipse?

Is there some template or something to implement iterface methods with accessing to wrapped member? For example, suppose I have public class MyClass implements List { private final List core; ... } and now I want to…
Suzan Cioc
  • 29,281
  • 63
  • 213
  • 385
11
votes
7 answers

NetBeans Code Templates ${date}?

I have this code template in Eclipse @since ${date} when entered i get something like this : @since 4.8.2009 But when i add the same template (@since ${date}) to NetBeans it outputs @since date Can someone help ? No answer yet ? Is this not…
Ari B
  • 123
  • 1
  • 7
10
votes
4 answers

Generating F# code

T4 is the "official" code generation engine for C#/VB.NET. But F# doesn't support it (this is from April, but I couldn't find any newer mentions). So what is a good way to generate F# code? EDIT: I want to implement 2-3 finger trees in F#. I already…
Alexey Romanov
  • 167,066
  • 35
  • 309
  • 487
7
votes
5 answers

Useful Delphi code templates

I've been programming in Delphi for a little over two years now, and I've only got maybe 5 custom templates, I feel as though I should have more. If anyone has any particularly useful ones it would be great to have a nice repository of them here on…
Peter Turner
  • 11,199
  • 10
  • 68
  • 109
6
votes
3 answers

Loop over fields in eclipse code template

Can you do loops in code templates, e.g I want to print all the fields in a class. Is there a template for that?
fastcodejava
  • 39,895
  • 28
  • 133
  • 186
6
votes
2 answers

Erlang Edoc in Emacs

Let's say that I have an Erlang function, with spec. -spec foo(integer(), string()) -> boolean(). foo(_Integer, _String) -> true. My dream would be to generate the edoc from this information within Emacs automatically. The generated…
Roberto Aloi
  • 30,570
  • 21
  • 75
  • 112
6
votes
2 answers

eclipse code templates - indentation

I have created a code template to add a logger and the corresponding import: ${:import(org.apache.log4j.Logger)} private static final Logger logger = Logger.getLogger(${enclosing_type}.class); If I add this now, the logger always starts at the…
jan
  • 3,923
  • 9
  • 38
  • 78
6
votes
2 answers

Code templates - unit name clash between Delphi versions

Different Delphi versions (in my case 2007, XE and XE2) seem to use the same code-template repository, such as ..\Documents\RAD Studio\code_templates. Since XE2 uses namespaced units, this causes problems when one have to use a unit name in a…
Sertac Akyuz
  • 54,131
  • 4
  • 102
  • 169
5
votes
1 answer

How to Import/Export live code template in android studio?

In Eclipse there is simply option to import or export code template. I want to do same in android studio but there is not any direction option to do so. I have create one template and now i want to apply it to all my other system so i need to export…
Chintan Khetiya
  • 15,962
  • 9
  • 47
  • 85
5
votes
2 answers

ReSharper - How to revert back to Visual Studio code templates

When creating a property in Visual Studio, I use the snippet prop and can TAB between the type and the name and Visual Studio jumps between the 2. ReSharper has taken over this functionality, and I would like to know how to reset it back to Visual…
Dave
  • 8,163
  • 11
  • 67
  • 103
5
votes
1 answer

NEW T4 Controller Template in MVC3

As you know to create new t4 templates in MVC, need to add CodeTemplates folder to project. There are two main subfolders 1-AddController, 2-AddView I always use AddView folder to add new templates to generate custom views, know I need new template…
Saeid
  • 13,224
  • 32
  • 107
  • 173
4
votes
3 answers

Writing a Java adder remover, method code template for Eclipse

There are too many time I encounter the need to write an adder/remover methods for lists: public void addSomething(Something something){ somethings.add(something); } public void removeSomething(Something something){ …
TacB0sS
  • 10,106
  • 12
  • 75
  • 118
1
2 3 4 5 6 7