intellij - way to do the eclipse CTRL+ALT+UP duplicate lines upwards and end up with carets in duplicated field?
Asked Answered
K

3

15

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.

Keratin answered 28/11, 2013 at 4:24 Comment(2)
An intellij plugin can do this. If you put a bounty of +100 I could write it for you :)Valoniah
Agreed, it would nice if IDEA had this "duplicate up" and "duplicate down" features but I don't think it does.Corves
B
14

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.

IntelliJ Keymap

Barbey answered 28/4, 2016 at 20:28 Comment(0)
D
12

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

Donough answered 14/9, 2017 at 6:28 Comment(1)
Sorry, it was not intentionally spam, is just a simple plugin I made for myself and I wanted to share. Anyway, I added some more information ;) Actually, I think now seems more like spam, like I'm trying to sell it hahaDonough
I
2

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.

Impassive answered 10/11, 2015 at 16:44 Comment(2)
I'm guessing this might only work for a single line selection unless Autohotkey can see the size of the selection. (also note, windows-only)Flippant
Could you post the ahk script section? Thanks.Abomination

© 2022 - 2024 — McMap. All rights reserved.