Vscode: No longer able to copy/paste without coloring

Created on 22 Feb 2017  路  16Comments  路  Source: microsoft/vscode

Refs: https://github.com/Microsoft/vscode/issues/21013

  • OS Version: Windows 10

Steps to Reproduce:

  1. hit Ctrl+C on a TS file
  2. paste into Google docs

=> the content is using the coloring
=> I am confused because there is an explicit command to copy with color info
=> now I seem to not be able to paste without coloring info anymore?

editor-clipboard feature-request

Most helpful comment

Please don't come up with half-baked solution like a "Copy without formatting" menu-item. Make this a user setting like "editor.copyWithFormatting" and with the options true/false.

All 16 comments

1
If it works with "paste without formatting"

@King66 which not every application is providing...

We don't have copy with syntax highlighting at the beginning so changing the behavior right now may surprise users but I still want to go with that because we are following the clipboard protocol. That's how browsers and Visual Studio is doing at this moment.

With this feature, we try to set another entry for text/html in the clipboard if it doesn't lead to noticeable lagging in Code. For example, if you are copying a large content which may even take 200ms to finish, we'll just set text to the clipboard.

For applications that handle pasting, IMHO if they support pasting with format, they usually support paste without format as well. The later is what OS gives you if don't specify a particular MIME type.

It's possible that the application forgets to add an option for users to paste without format. Different applications may have different default behavior about which MIME content to paste as well. But I'll go with current behavior as the user reactions are good after having it in Insider for a week.

Makes sense, let's see how it goes.

I noticed a particular annoying behaviour since the copy-with-highlighting feature was made default: We use Microsoft Teams and when you copy from vs code with dark theme into Teams you always have to remember to copy without formatting, and more often than not people forget it, and the result isn't pretty if you do forget it as Teams doesn't paste the background colour, so you end up with text colours which are meant for dark background, but you display it on a white background, nearly not readable. In Word it looks as intended, with dark background. If you paste it into Google Docs, the colouring is right but the lines are all different sizes (dark background doesn't fill empty space to the right in shorter lines) and there are white spaces between the dark background lines which I can remove by changing the line spacing.

So, somehow I have the feeling that this could be a nice feature but just doesn't work in many cases as it is intended. The ideal way would be to copy the semantics (it is "code") and the language (like "C#") so that the receiving app can do its own syntax highlighting, but of course that's not going to be a reality any time soon.

Please don't come up with half-baked solution like a "Copy without formatting" menu-item. Make this a user setting like "editor.copyWithFormatting" and with the options true/false.

Copy with formatting in VSCode now "forces" me to run sublime/notepad as formatting filters. So what I do today is this:

  1. Select and copy text in VS Code
  2. Paste text in sublime/notepad
  3. Select and copy text in sublime/notepad
  4. Paste text where I would like unformatted text

Before the formatting copy/paste in VSCode this is what I did:

  1. Select and copy text in VS Code
  2. Paste text where I would like unformatted text

For me personally I use copy without formatting for most of my use-cases and only ~5% of my use-cases calls for copy with formatting.

I would very much like a way to disable copy with formatting whether it's a setting or a new command.

Another workaround without opening Sublime is to open a new file (Cmd + n) which will be plain text, copy paste there, and then copy paste again :(

"...changing the behavior right now may surprise users but I still want to go with that because we are following the clipboard protocol." - rebornix

Wow. See https://en.wikipedia.org/wiki/Principle_of_least_astonishment - I would hardly have been more astonished if I had pasted a bitmap image.

Thanks to akras-apixio for the new file, paste, and copy means of scrubbing the unwanted theme and syntax coloring. That feels better and more cross-platform than launching notepad for the purpose. I suppose I could find an add on that already does this.

As so many comments on #20837 request, please choose a less astonishing default, preferably copy without any formatting, copy with a default light "copy theme" if you must.

On those occasions when I _do_ want to copy with formatting, I might also want to copy line numbers as well (good for email, and wiki documentation) but maybe not (if it may be useful for further copying and pasting), so more options would be helpful.

I'd like to have a setting:
copy without coloring
copy with theme1
copy with theme2

I want to use dark theme and copy with light theme

It is true that browsers are doing it, IntelliJ is doing it too. Why people like this approach is beyond me. Formatting without the context of whole page rarely has any meaning. At least IntelliJ allows me to disable this. VSCode should follow.

Anyone who tries to tell me that this is a good behavior and everyone is happy should read this [1] SO question to see how people are trying to work around it. Is this a good design, which makes users jumping through hoops to get around it?

[1] https://stackoverflow.com/questions/122404/how-to-copy-and-paste-code-without-rich-text-formatting

Just noticed in other issue that somebody wrote extension called CopyPlainText: https://marketplace.visualstudio.com/items?itemName=p26frqxxfmwrzekd6c6fcty5kipjkr3gaeejzpkyy42p5udjkjyq.copyplaintext

Works really well. (And kind of ridiculous that it had to come to this IMHO.)

I'd just like to point out that I really think this is a bug with respect to the default behavior of VS Code. Right now, we have two commands:

  1. Copy: editor.action.clipboardCopyAction (CTRL + C default binding)
  2. Copy with Syntax Highlighting: edtior.action.clipboardCopyWithSyntaxHighlightingAction

To me, that would imply that the plain "Copy" is copy without syntax highlighting. But that doesn't seem to be the case.

@rsyring now:
Copy: copy with syntax highlighting when selected text length less than...
Copy with Syntax: copy with syntax highlighting

With this great PR https://github.com/Microsoft/vscode/pull/54155, we can now disable the copy with syntax highlighting behavior by setting editor.copyWithSyntaxHighlighting to false from tomorrow's Insiders and next Stable. Command "Copy With Syntax Highlighting" would always work not matter of the value of this setting, so you can bind another specific keybinding for this command.

Lastly thanks for all your patience, feedback and great contribution to this issue. Happy Coding!

Thanks, then I can finally uninstall Sublime :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

omidgolparvar picture omidgolparvar  路  3Comments

villiv picture villiv  路  3Comments

biij5698 picture biij5698  路  3Comments

sirius1024 picture sirius1024  路  3Comments

ryan-wong picture ryan-wong  路  3Comments