Editing Wishlist -> Duplicate lines & Insert line at cursor position

Coming from eclipse, I am missing two features in IntelliJ desperately:

a) Duplicate the selected lines *as a whole*, thereby ignoring caret positon


At the moment CTRL + D will duplicate the selection at the caret position only.
In eclipse, this will result in duplicating the complete lines that contain selected characters.

Example [marked content is underlined, copied content is italic]:

The quick brown fox jumps over the lazy dog

The quick brown fox jumps over the lazy dog

* IntelliJ:

The quick brown fox jumps over the lazy dog

ThedogThe quick brown fox jumps over the lazy dog

* Eclipse:

The quick brown fox jumps over the lazy dog

The quick brown fox jumps over the lazy dog

The quick brown fox jumps over the lazy dog

The quick brown fox jumps over the lazy dog  

To me, it would be great to have an configuration option to toggle this duplicate behaviour.

b) Pressing CTRL+ENTER in eclipse inserts a new line at the caret and sets the caret to the indented first editing position.


I have read about this feature called smart indent but toggling it doesn't affect what I am looking for. Maybe you could introduce an option to decide whether CTRL+ENTER will break the current line or not while insert a new line.

Example:
*START*


protected String callGrandFather() {     
     return [cursor]super.say();
}



*END*  

Pressing ENTER at [cursor] position should result in

*START*


protected String callGrandFather() {
     [cursor]
     return super.say();

}


*END*

Could you please feedback on this two issues? Thanks a lot.

PS. I am aware of macros and tools like AutoHotKey but do not want use them for things like clipboard pollution and others

6 comments
Comment actions Permalink

Hello Romeo,

Welcome to the IntelliJ IDEA community.

In regards to feature (a) you mention...  <Edit>See Denis' answer below</Edit>


In regards to feature (b), that feature ("Start New Line Before Current") is by default mapped to Ctrl+Alt+Enter. You can map it to Ctrl+Enter if you like in Settings (Ctrl+Alt+S) > IDE Settings > Keymap. (You'd first want to remap "Split Line" from Ctrl+Enter to something else.) Also, in the keymap settings, there is an "Eclipse" settings profile you can select which will use (for the most part) Eclipse hot keys for actions.

Another tip for you as you transition from Eclipse: If you are looking for an action, you can use the "Find action" action. This is (by default) mapped to Ctrl+Shift+A. Or is is available in the menu via Search > Find Action in IDEA 10 & earlier; or (currently) via Help > Find Action in IDEA 11 EAPs (i.e.betas). For example, if you open that search box and enter "new line" (without the quotes), you'll see the Start New Line Before Current action listed. The hard part sometimes can be knowing what an action is called (is it "new line" or "add line" or "insert blank line", etc.) But most actions are intuitively named and can be found in the first try or two.

I hope that helps.

Again, welcome to the community. I hope you enjoy using IntelliJ IDEA as much as we all do.

Best Regards,
Mark

0
Comment actions Permalink

Hi Romeo,

Thanks to Mark, he has provided the answer for b), as for the a) you can reassign Ctrl+D (or any other convenient shortcut) from 'Duplicate Line or Block' action to 'Duplicate Lines' that does exactly what you want.

Denis

0
Comment actions Permalink

denis.zhdanov wrote:

Hi Romeo,

Thanks to Mark, he has provided the answer for b), as for the a) you can reassign Ctrl+D (or any other convenient shortcut) from 'Duplicate Line or Block' action to 'Duplicate Lines' that does exactly what you want.

Denis

Nice. I never even knew the Duplicate Lines action existed (obviously). Good to know.

0
Comment actions Permalink

Hi and thanks for your answers, Mark and Denis.

a) for the interested reader: the action ist called "EditorDuplicateLines" and is located in  AllActions/EditorActions/. Making it more constistently, maybe renaming the feature to "Duplicate Lines" makes sense. Interestingly, in my version (10.5.2) the action does not show up when typing "EditorDu" in the filter box, having chosen the "Default" keymap.

b) sadly, the feature "Start New Line Before Current" is not available in my version (s.a.). CTRL+ALT+Enter ist currently mapped to diverse "properties" - no editor action. I have attached an image as evidence :-) ("Eingabe" is the german translation of Enter)

Again, thanks for your support.

Regards,
Romeo



Attachment(s):
ctrlAltEnter.jpg
0
Comment actions Permalink

Glad to help Romeo. Sorry that I did not realize the "Start New Line Before Current" was added in the IDEA 11 EAP. For 8 or 9 years I've always used the latest EAP build. So trying to rmember when things were added to IDEA becomes one big blur since I see them appear incrementally. I thought the "Start New Line Before Current" was in 10.x.

0
Comment actions Permalink

Hello Mark,
so I'm looking forward to the next stable build. Again thanks for your help
Best regards,
Romeo

0

Please sign in to leave a comment.