36

In visual studio code, if you press ctrl + c on a blank line, with nothing highlighted, it copies the blank line.

I thought there may was an option to disable this, but haven't been able to find it.

Sol
  • 949
  • 1
  • 11
  • 23
  • 1
    There is an option in (regular) Visual Studio for "Apply Cut or Copy commands to blank lines when there is no selection." I don't know if VSCode has a similar option, but that's some text you might look for. – BJ Myers Mar 03 '17 at 20:31
  • I wanted the opposite of the OP. The setting `editor.emptySelectionClipboard: true` works, but not when the vim extension is enabled :-( – Tyler Collier May 03 '17 at 23:14

2 Answers2

60

You should be able to do this by configuring the option editor.emptySelectionClipboard to false.

Bill_Stewart
  • 22,916
  • 4
  • 51
  • 62
  • 2
    "editor.emptySelectionClipboard": false Works GREAT! :) – Sol Mar 04 '17 at 17:07
  • 11
    For me, this disables copying/cutting a line with ctrl-c/x when I have nothing selected. I only want to disable cutting lines that only contain whitespace... – N. McA. Mar 22 '17 at 22:31
  • 1
    If you don't like how the command works, you probably need to write your own extension or request an enhancement on the [issues page](https://github.com/Microsoft/vscode/issues). (I didn't write the code that implements the behavior you don't like, so it's a bit pointless to complain about it here.) – Bill_Stewart Aug 11 '20 at 19:38
  • Is there a similar option in Visual Studio 2022 too? I can't find it – Fabio May 16 '23 at 15:49
  • 3
    @Fabio it's in Options->TextEditor->General "Cut or Copy the current line without selection" I don't know why anyone would ever want that to be turned on. I've accidentally duplicated lines so many times, causing build failures, just because there was no selection. – Eyelash May 18 '23 at 07:47
4

There is an extension for it: https://marketplace.visualstudio.com/items?itemName=usernamehw.do-not-copy-empty

nvd
  • 2,995
  • 28
  • 16