Plugin Icon if
  • Code Tools
  • Code Editing
  • Completion

Custom Postfix Templates

Обновлено:
5 месяцев назад
Версия:

2.22.0.242

Обзор
Версии

Обзор

Documentation | Screencast | Predefined templates

This open source plugin lets you define your own postfix templates for Java, Scala, SQL, PHP, Kotlin, Python, Dart, JavaScript, Ruby, Rust, Go and Groovy. It also comes with hundreds of useful postfix templates shared by the community. You're welcome to contribute your templates as well.

Apart from the community approach, how does the plugin differ from IDEA's postfix templates?

Since IDEA 2018 you are now able to define your own postfix templates for some languages in the settings UI (Editor → General → Postfix Templates). However, this is a pretty new feature and it's less functional than this plugin. Here are some of the advantages of this plugin:

  • You can define different template rules (context based) for the same template name, e.g. .toList should behave differently for arrays and for sets.
  • You can use template variables (e.g. $varName$) which are filled in by the user while applying the template.
  • You can use live template macros to automatically fill some of the template variables (e.g. $var:suggestVariableName()$) as well as you can define default values.
  • You can restrict the availability of templates or template rules to the availability of certain classes or libraries (e.g. expand "test".val to val s = "test" if Lombok is available).
  • It allows you to use static imports instead of class imports (e.g. array.toList can be expanded to asList(array) instead of Arrays.asList(array) if you add [USE_STATIC_IMPORTS] to the rule).
  • It comes with more than 500 editable postfix templates with more than 700 template rules, e.g.
    • string.toInt → Integer.parse(string)
    • array.toList → Arrays.asList(array)
    • file.lines → Files.readAllLines(file.toPath(), Charset.forName("UTF-8"))
    • file.getName().val → final String name = file.getName();
  • There are multiple ways to easily share your templates with others.

Версии

Версия
Диапазон совместимости
Дата обновления
2024
2.21.0.242
242.20224+
11.08.2024
Скачать
2025
2.22.0.242
242.20224+
20.02.2025
Скачать
Plugin ID:
de.endrullis.idea.postfixtemplates
icon