Bug: copy/paste from Visual Studio Code adds text styles

I’m not sure if this was happening before, or if it’s down to the text descriptions (which are grey)

  1. I added the text descriptions to a couple of fields
  2. Copy/paste adds grey styles and a div, weirdly
  3. Removed text descriptions from the fields
  4. Copy/paste still has this behaviour
  5. Currently have to paste in HTML mode and that works ok.


This doesn’t have anything to do with text descriptions (the “Text to show inside the field when it’s empty” in the Fields… edit window for a given field).

Copy/paste always preserves the HTML formatting of the original, unless you either:

  1. hold down the Shift key while doing the paste
  2. permanently alter the behavior by going to Tools / Preferences / Editing and check the “Paste without shift key strips formatting” checkbox

If you have been copy-pasting text from random web pages all along, there’s a good chance that you have a bunch of HTML in various fields of various notes without realizing it.

In the Browse window you could search for:
or similar HTML tags.


I understand the concept of pasting formatted text, I’ve dealt with this before in WYSIWYG editors. I didn’t expect that a flippin’ text editor would add junk when you copy/paste text however.

In TextEdit (Mac) for instance, in rich text mode it adds formatting. In plain text mode, it doesn’t. So I don’t know if there’s something that can be done on your end, but there’s a fix here:

  • In settings.json: "editor.copyWithSyntaxHighlighting": true
  • In the settings panel, search for: “copy with syntax highlighting”

Seems like a super annoying thing to be added by default in what should be a plain text editor!

  • FYI: even with CMD+SHIFT+V it still adds the divs to the copied text.

Thanks :+1:

Note: there was one beta version of 23.12 (namely 23.12beta2) where this was briefly broken, and it always kept the HTML formatting no matter what. Make sure you don’t have that old beta version. Check Help / About, it should show something like “Version ⁨23.12.1 (1a1d4d54)⁩” if you have the latest.

If you double-checked this and it still happens in the latest Mac version, it’s a bug that should be reported.

Personally I just use the Preferences setting I mentioned in the previous message.

Thanks for that. Yes I’ve checked and I’m indeed at Version ⁨23.12.1 (1a1d4d54)⁩.

Funnily enough I’m checking it today (after setting the option I mentioned to false) from different file extensions — it seems ok.

It’s adding a bit of junk from this text example:

An example of [intervals](https://www.mathsisfun.com/sets/intervals.html).

- `[` symbol means **include** the number.
- `(` symbol means **exclude** the number.

It’s adding some <br><br>&nbsp;&nbsp;&nbsp; (rather than <p> tags or spaces); but otherwise doesn’t seem to be causing problems today.

I’ll add a bug report if it starts up again.

And yes, I’ll try that preference setting too! :+1:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.