4

I want to create a live template to wrap a code before the dot.

Example:

  1. I enter userDao.getUser().asst
  2. Press enter
  3. Code is wrapped and the result is: assertThat(userDao.getUser())

So basically I want to create a live template with functionality similar to sout, try, listOf etc. Can you suggest how to create it?

2 Answers2

7

You can use Postfix Completion for that.

enter image description here

The result will look like this:

enter image description here

Koyasha
  • 5,275
  • 2
  • 8
  • 17
1

Not exactly what you need but as an alternative;

  • Settings
  • Live templates
  • Surround
  • Add following line in the template text, write asst(or a for shorter version) in the abbreviation input field.
assertThat($SELECTION$)$END$
  • When you type userDao.getUser() and hit cmd + alt + j , you will have Select Template pop-up. When you then hit a it will automatically surround it with assertThat.
Ersoy
  • 8,816
  • 6
  • 34
  • 48