how to change behaviour of duplicate line(s)

Hi,

This is how it works in phpStorm:
- duplicate line with no text selected - duplicates the whole line
- duplicate line with text selected (does not matter single or multiple lines) - it will duplicate only selection

This is how I would like it to work (and as it works in Eclipse):
- duplicate line with no text selected - duplicates the whole line
- duplicate line with text selected in multiple lines - duplicate all lines including new lines
- duplcate line with text selected in single line - duplicate selected text - this could be nice, but I don't really care for it

PhpStorm is great tool but I am still strugling with this behaviour. I know that maybe Eclipse was an exception with this behaviour but still for me it was more usable.

Sooo the question is: is it possible to get this kind of behaviour in phpStorm?
Tried searching setting - could not find it. What else could be done?

Thanks!

2 comments

Hi there,

Sooo the question is: is it possible to get this kind of behaviour in phpStorm?

Yes and No.

Yes, you can; but not with the same shortcut (for all 3 desired behaviours).

  1. Settings | Keymap
  2. Search for "duplicate" (without quotes, obviously)
  3. You will notice that there are two actions available:
    • Duplicate Line or Block (Ctrl+D in default keymap) -- will duplicate selection block (if available); otherwise it will be the whole line;
    • Duplicate Line (has no shortcuts in default keymap) -- will always duplicate full lines
  4. You can now assign different shortcuts to them (or just swap them around)


screen01.png

0

This is briliant. I cannot believe I did not find it before.

Thanks a lot!

0

Please sign in to leave a comment.