I want to duplicate just like the standard CTRL+D hotkey in intellij, but in the eclipse version was a way to end up in the duplicated lines with the caret. E.g. the original is at the bottom and you are set to edit the duplicated lines at the top with the caret.
E.g. CTRL+D does this
| <-- caret
originaltext| (hit CTRL+D) you end up with
duplicatedoriginaltext
originaltext|
but what i want
duplicatedoriginaltext|
originaltext
is there a way to do this in intellij? and obviously this has to work with several lines as well.
IntelliJ has a feature similar to eclipse's CTRL+ALT+DOWN
feature. It's not set by default, and you can set it in the Keymap
under the Editor Actions
grouping. Its called Duplicate Lines
.
A bit late to the party but I created a plugin to do just that:
https://plugins.jetbrains.com/plugin/10008-duplicate-lines
Supports single lines, multiple selected lines, multiple carets and block selection.
Default shortcuts are "Shift + Ctrl + Alt + Up/Down" and "Shift + Command + Option + Up/Down" for macOS.
And is compatible with IntelliJ IDEA, PhpStorm, WebStorm, PyCharm, RubyMine, AppCode, CLion, Gogland, DataGrip, Rider, MPS and Android Studio.
Source code: https://github.com/xusoo/duplicate-lines-intellij-plugin
I can tell you how I solved this problem. I use Autohotkey and just mapped Ctrl+Alt+Up to duplicate line, then move the line up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With