8

I'm using Sublime 3083.

Suppose I cut some text (Ctrl-x) in a file and then attempt to paste it somewhere else, in that same file or another one.

  1. I position the cursor on the line I want to paste the text.

  2. If I hit Ctrl-v the text is pasted with no issues.

  3. But if I accidentally hit Ctrl-c instead, the text that was cut can no longer be pasted. It is dropped from the clipboard and I'm forced to Ctrl-z back to the point before the text was cut.

This happens even if no text is selected when hitting Ctrl-c.

I tested and this behaviour seems to be exclusive from Sublime. Is this a feature? If so, can it be disabled?

Gabriel
  • 40,504
  • 73
  • 230
  • 404

2 Answers2

15

There is a setting in Preferences > Settings - Default which can change the behavior:

// If true, the copy and cut commands will operate on the current line
// when the selection is empty, rather than doing nothing.

"copy_with_empty_selection": false,

Changing it to false should make it so that it doesn't copy an empty selection.

l'L'l
  • 44,951
  • 10
  • 95
  • 146
  • That was it, thank you! What possible use can this option have? Why would you want those shortcuts to operate on empty selections? – Gabriel Jun 25 '15 at 22:30
  • 3
    Well, I guess if someone is lazy and doesn't want to select the entire line and copy it then the setting will do it for them by placing the cursor anywhere... :) – l'L'l Jun 25 '15 at 22:32
  • 1
    Ohhh I see now. Hadn't even occurred to me that it could be used to do that. Thanks again! – Gabriel Jun 25 '15 at 22:34
  • 1
    Is it possible to enable this, but with a different keyboard shortcut? It seems like it would be useful in certain situations. However, I currently only ever do it by accidently hitting ctrl+c (or, even worse, ctrl+x) when I mean to push ctrl+v, and deleting my clipboard at the exact moment I was ready to paste makes me something something. Go crazy? DON'T MIND IF I DO!! – jmorganmartin Aug 21 '15 at 03:53
  • 1
    @jmorganmartin Not exactly what you want probably, but you can ctrl+L to highlight the line, then ctrl+C to copy it. It's obviously not a single command and it has the side effect of including any line break at the end, but it's built in. – Joel Mellon Apr 06 '17 at 17:49
4

Add this to your User settings:

"copy_with_empty_selection": false

Step-by-Step:

  1. Preferences > Settings
  2. A new window will open with 2 files:

enter image description here

  1. In sublime-settings -- User (the one on the right) paste this:

    "copy_with_empty_selection": false

Why?

If you do it in Default settings it will be overwritten when sublime updates. Any changes you make to settings should be in User Settings.

Community
  • 1
  • 1
Travis Heeter
  • 13,002
  • 13
  • 87
  • 129