0

My goal is to type the following statement as fast/effective as possible using IntelliJ IDEA:

List<String> list = new ArrayList<>();

This is what I tried:

  • use code completion List<String> list = new |, but too much to type
  • use post fix code completion new ArrayList<>().var|, but still too much to type

Note | means Code complete here

In NetBeans there is a simple template like "al", which creates the statement above. I did not found such a live template in IDEA for that. Did I miss an important usage pattern in IDEA?

EDIT: That is not a dumb noobie question. I recently switched to IDEA and haven't grasp all things to be productive. Yes, I could define my own live template and then persist it in a configuration file to share it with my working computer or create a plugin, which provides my template. But that is not the question. Is there a fast standard/built-in way to do it?

Ben
  • 2,235
  • 18
  • 17
  • 1
    My solution (that's widely applicable to all sorts of snippets and IDEs but might not be for everyone) was to learn to touch-type. – NPE Aug 08 '17 at 19:33
  • 2
    Can't you create code templates there too? A quick google search yields many results. I'm no expert at IntelliJ thus comment only. – Zabuzard Aug 08 '17 at 19:35
  • A fun way to learn touch typing is found [here](http://store.steampowered.com/app/246580/The_Typing_of_The_Dead_Overkill/). – Adam Arold Aug 08 '17 at 19:35
  • You can type `List list = new ArrayList<>();`, copy it to your clipboard, and paste it at any time :) – Jacob G. Aug 08 '17 at 19:40
  • Or use any hotkey-program that automatically enters this text after hitting a specific hotkey. – Zabuzard Aug 08 '17 at 19:49
  • Live Templates. But I usually write "new AL", ctrl+shit+Space to autocomplete, then intruduce variable. – Meo Aug 08 '17 at 19:50
  • 1
    @Ben your question looks like a duplicate of https://stackoverflow.com/a/44834284/104891. – CrazyCoder Aug 08 '17 at 19:56
  • @CrazyCoder: Yes, that matches my question! Thank you. But gives no answer, if there is a fast default way. – Ben Aug 22 '17 at 20:29
  • @Ben there is nothing default. you will need to add a template. – CrazyCoder Aug 22 '17 at 20:36

1 Answers1

2

You can create your own templates if you feel you need more to what IntelliJ provides

Read this link on IntellJ on code completion

Jeeppp
  • 1,553
  • 3
  • 17
  • 39
  • 3
    Can you include the essential parts of that link here, or just quote them? It's better if questions and answers at SO are self-contained. Also the link could become invalid in the future. – Zabuzard Aug 08 '17 at 19:37
  • Thanks. I know, but is there anything default in IDEA for that? I do not like to configure my IDE for that. – Ben Aug 08 '17 at 19:39
  • I did not knew that – Vijay Nov 24 '20 at 08:20