Forum Discussion
Why does Teams always strip indentation when pasting text?
It's fairly common to want to post code in teams (without using the special formatting for code snippets).
The markdown like syntax for code works pretty well when typing code and it preserves indentation. But when you paste XML or JSON all the indentation is removed. Why?
Here's an example:
That XML was indented in the source. But whenever we paste JSON or XML we lose indentation. Unless we take the extra effort to use a code snippet. Or manually type it for small examples.
my-kl
So I got to the heart of the matter. I used the Clipboard Inspector to inspect the contents of clipboard when copying the same text from two different apps. Both have two entries. One of the entries is text/html and one is text/plain. The text/plain as you might guess is identical. The html is quite different. I then copied the html and rendered.
This is what I see from TextEditThis is what I see from Visual Studio Code
So this would appear to be an issue with my environment in Visual Studio Code (or even a defect in Code, I"m not sure)
- agallowayCTACopper ContributorTeams really needs to prioritize code formatting fixes if they ever want to be as useful as Slack and Discord are, which are currently both leagues ahead of Teams when it comes to developer communication.
I expect format preservation and language-specific syntax highlighting to be a standard feature in any modern chat client these days. I shouldn't have to spend more time fighting against the client to do what I need it to do than it takes to write the actual message. - joboa655Copper ContributorPernille-Eskebo - were you going to fix this? Should we move back to slack?
- my-klBrass ContributorI'm the OP. My guess is this is not the correct place for bug reports. I'm not sure what the correct forum to report bugs for Teams is.
- michaelfsCopper Contributor
MS has been ignoring our bug reports for months at this point. I have no idea why my company switched to this garbage pile.
- hanvyjCopper Contributor
This needs fixing ASAP. It's absolutely ridiculous not to be able to paste code in a chat app and have it strip out whitespace.
It's not even whitespace at the start of lines, it strips out consecutive whitespace within pasted text too. Spaces, tabs, anything.I work in a team of software developers, it's outrageous such a simple thing doesn't work.
- dbompCopper Contributor...and the code snippet is not a substitute. It only displays five lines without expanding, and the entry is through a thought-interrupting popup. The "Monospaced" formatting was just fine for medium length pastes. (Actually, what is the point of monospaced formatting when the whitespace is collapsed? When is it even useful?)
- spinardCopper Contributor
dbomp Agreed code snippet is not a workaround. Not only for the reasons you stated, but also because you can't apply any other text formatting to the code snippet. One thing I do quite a bit (or used to) is paste a bit of code, then highlight the part I want to draw attention to. This woks in a Monospaced paragraph (but now the spaces are stripped so that's now useless).
- WeetACopper ContributorYop,
I had the habit of pasting using CTRL+SHIFT+v inside a monospaced block created with triple backquotes.
Indent was OK.
Since few weeks, it doesn't work anymore.
Indent is lost.
Not sure why - GregB945Copper Contributor
same issue when not pasting, but just typing... trying to write up pseudo-code to colleagues while explaining a concept, and all indentation, leading white space is stripped. Quite frustrating. I know we can spend the extra time to create a little code snippet tool, but when writing back and forth to colleagues on code design and concept, it just isn't practical
- NshawCopper Contributor
Yeah... Teams is total garbage. Let's not make excuses for Microsoft by saying the problem has a workaround. This is the most basic stuff there is.
If you copy plain text to your clipboard, you should be able to paste it into Teams without having it strip leading spaces. Copying from most applications will put plaint text as well as a few different forms of formatted text (rich-text, html). This way, if you are pasting to an application that understands those formats, you can keep all the extra colors/fonts/tables/etc. Many applications even give you this control when you paste, by having another option under the Edit menu that explicitly says, "Paste in plain text". The equivalent (you'd think) in Teams says "Paste and Match Style", except, it still strips your spaces.
I noticed recently that when I'm typing a message in Teams, typing cmd-a (the equivalent of ctrl-a on Windows), that shortcut seems to be completely ignored. I can click Edit > Select All... but I don't want to touch the mouse for a shortcut that Microsoft invented... it's been around since at least Windows 3.0. How is it that they keep managing to bugger up TYPING in Teams?!?
- GregB945Copper Contributor
Nshaw funny you say that, I (on a Windows machine, therefore using ctrl + a) also have the same issue lately, it's like they completely removed keyboard shortcuts.
There are many times I am typing a response and the conversation goes a different direction while I type and therefore need to trash what I was writing, going to try ctrl + a and rewrite a new message, I now need to use my mouse just to delete the current text... frustrating!
- Giacomo_Mc_EvoyCopper Contributor
Hard to believe that this discussion has been around for 1 year and nothing has changed. What needs to happen for Teams to be useful for exchanging code?
If I copy and paste code as a quote, I can see it gets stripped of whitespace while I am writing the message. If I fix this in the quote box and then send it, it still gets sent without the whitespace! This is simply unacceptable.
And I have tried the code snippet. Apart from being slow and clunky, if the lines are too wide then you cannot read the code from the chat. There aren't any scroll bars either, you just cannot read the code without blindly selecting the truncated rows and pasting them somewhere else.
- my-klBrass Contributor
Giacomo_Mc_Evoy I think the issue is that I opened this up in a "community forum" rather than filing a bug in the appropriate place. I haven't investigated where bugs should be opened for Teams.
- my-klBrass ContributorI just did a search for how to report an issue. One way is to use the Help | Give Feedback option within Teams itself, which I just did. We'll see if that helps.
- Giacomo_Mc_EvoyCopper Contributor
Hello! Thanks for answering. I also just noticed that this is a community forum, not exactly a bug reporting tool. I have also used Help -> Give Feedback, let's see if that helps somehow.
- my-klBrass ContributorThis is on macOS, colleagues tell me they don't have an issue on Windows.
- my-klBrass ContributorOk some more sleuthing:
If I copy from Visual Studio Code and paste into Teams (on macOS) this problem happens.
If I copy from TextEdit or Visual Studio and paste into Teams, the indentation is fine.
So this is weird interaction between Teams, the clipboard and Visual Studio Code.
But, I can copy from Visual Studio Code into TextEdit and everything is fine. Then I can copy from TextEdit and paste into Teams and everything is fine.
Anyone have a firm understanding of how the clipboard works and what app might be working incorrectly? Seems perhaps Teams is confused by meta data from Visual Studio Code?- my-klBrass ContributorUsing this website I was able to examine the clipboard data from TextEdit and Visual Studio code.
The text/plain entries look identical, but the text/html entries are radically different. That seems to be a clue.
- mpowrie1Copper ContributorFor the past few weeks I have this problem on Windows 10 and VS Code
- __om__Copper Contributor
I started to observe the issue with stripped spaces and tabs for preformatted text pasted may be month ago (Windows 10).
The most annoying thing is inserting the code parts (even from Notepad or Notepad++).
Is there any workaround for this?
- tilmanccviCopper ContributorThis happens with purely `text/plain` clipboard content, e.g. when copying from Notepad++, so this definitely is a bug in Teams not any specific source application.
- dkaszews-intelCopper ContributorStill a problem on 1.5.00.5967. Anything pasted gets its leading whitespace trimmed, even when pasting into code block (!), making it unusable for pasting any code. Code snippets are not viable workaround, as they cannot be quickly accessed with mouse and are automatically collapsed.
- krzysztowCopper Contributor
dkaszews-intel fully agree it's like a broken feature atm, not usable...