Duplicate the whole method with a keyboard shortcut?

I often use Ctrl + D to copy one line of code.

Is there a keyboard shortcut in IDEA where I can put a carriage in the method name and press a key combination to duplicate the whole method? Ctrl + D does not help in this case.

+4
source share
2 answers

Until IDEA gets a built-in function like this, you can use this approach (pretty quickly):

  • Place the caret on the method name bar or somewhere inside the method itself
  • Ctrl + Minus
  • Ctrl + D
  • Ctrl + Plus

Or create a macro like @CrazyCoder.

+6
source

You can use the first Ctrl + W to select a method. Then Ctrl + D to duplicate the selected lines.

0
source

Source: https://habr.com/ru/post/1495990/


All Articles