51

I have recently started using Intellij and I noticed that by default, when you do ctrl+c for copying something when you have nothing selected, it copies the entire line into the clipboard overriding what I had in there before.

This is really annoying yet I cannot seem to figure out how to disable it. I am aware that there is a paste history you can use however this is not what I am after, I just want to disable it like you can do with sublime text.

Is there a way to disable this behaviour so that when I press ctrl+c and nothing is selected it just leaves the clipboard alone?

Alexandre Thenorio
  • 2,288
  • 3
  • 31
  • 50

4 Answers4

79

Since version 2021.2 there is a dedicated Don't copy/cut the current line when invoking the Copy or Cut action with no selection setting for this in Preferences | Advanced Settings on the Mac, Settings | Advanced Settings on other platforms.

For older IntelliJ Platform based IDE's the setting is more hidden:

Invoke Help | Find Action... (Ctrl (Cmd on Mac)+Shift+A), type Registry and select the Registry... item that appears. Enable the editor.skip.copy.and.cut.for.empty.selection option there. Be careful with the other configuration options, because it is possible to break your IntelliJ IDEA installation with an incorrect setting.

Registry window

Bas Leijdekkers
  • 23,709
  • 4
  • 70
  • 68
  • 13
    Awesome. I dont know why this is hidden so deep within Intellij but that's exactly what I was looking for. Thank you – Alexandre Thenorio Oct 05 '15 at 10:22
  • 4
    @Bas this has not worked for years the above shortcut must have been changed either way you must provide an alternative way to open it in case it does not work. this is by far the most-viewed intellij issue as no sane dev on earth wants to copy emptiness and yet the solution is held out of reach. – tatsu Dec 21 '17 at 13:48
  • 3
    @Dilapidus I made him update the answer. the above now works yes. – tatsu Feb 21 '18 at 08:52
  • 6
    Heck! That drove me crazy! – Tertium Jan 23 '19 at 09:09
  • 2
    This solution doesn't work in RubyMine (and I suspect Jetbrains moved it, since this answer is getting old). You can now find this as a settings option in Preferences > Advanced Settings > Don't copy/cut the current line when invoking the Copy or Cut action with no selection. – Stefan Mohr Sep 22 '21 at 21:46
  • There is no "Preferences" – Philip Rego Jul 25 '22 at 21:56
  • It's named "Settings" on Windows and Linux. – Bas Leijdekkers Jul 26 '22 at 08:12
6

In Mac OS X:

  1. Press cmd+shift+a.
  2. Type registry and press return to open the Registry.
  3. Enable the editor.skip.copy.and.cut.for.empty.selection option.
  4. Click Close.
Rob Johansen
  • 5,076
  • 10
  • 40
  • 72
2

I suppose it should be same as in WebStorm, or someone might be searching WebStorm solution as I did:

  • Open the settings: File > Settings > Advanced Settings (bottom of the list).
  • Start typing "editor".
  • Check the editor.skip.copy.and.cut.for.empty.selection
  • Click "OK" or "Apply"

On: WebStorm 2022.3.1 On: WebStorm 2022.3.1

ado387
  • 162
  • 1
  • 9
-1

in PHPStorm -> From the Help menu, select Edit Custom Properties. and paste

editor.skip.copy.and.cut.for.empty.selection = true

  • This solution was already previous mentioned. As a tip: When you answer old questions you should take your time to make a high quality answer. – fuggerjaki61 Jul 22 '20 at 14:42
  • Sorry, but Google gives this question when requesting for **PHPStorm**, and there the previous solutions do not work – Victor Palyuha Aug 14 '21 at 20:40