[WSL] Newlines when copying from console #55

Closed
opened 2026-01-30 21:40:47 +00:00 by claunia · 34 comments
Owner

Originally created by @strarsis on GitHub (Jan 23, 2018).

  • Your Windows build number: Microsoft Windows [Version 10.0.16299.192]

  • What you're doing and what's happening:
    Select text in a (WSL/Bash on Windows) console using the mouse and
    copying it using right mouse button.

  • What's wrong / what should be happening instead:
    The resulting text (when pasted) got no newlines but lots of whitespace between the lines instead.

Originally created by @strarsis on GitHub (Jan 23, 2018). * Your Windows build number: Microsoft Windows [Version 10.0.16299.192] * What you're doing and what's happening: Select text in a (WSL/Bash on Windows) console using the mouse and copying it using right mouse button. * What's wrong / what should be happening instead: The resulting text (when pasted) got no newlines but lots of whitespace between the lines instead.
claunia added the Product-ConhostIssue-BugNeeds-Tag-FixArea-Interaction labels 2026-01-30 21:40:47 +00:00
Author
Owner

@FilipBB commented on GitHub (Jul 25, 2019):

Is there are workaround for this? It makes copying from the terminal very difficult, and I'm finding myself opening WSL directly just to copy text out.

@FilipBB commented on GitHub (Jul 25, 2019): Is there are workaround for this? It makes copying from the terminal very difficult, and I'm finding myself opening WSL directly just to copy text out.
Author
Owner

@strarsis commented on GitHub (Jul 25, 2019):

@FilipBB: There are some workarounds:

  1. Pipe the command output into a text file, open the text file in a Windows editor to copy its contents.
  2. Copy the tmux (or screen or whatever terminal multiplexer is used) buffer into clipboard using a shortcut/built-in command.
@strarsis commented on GitHub (Jul 25, 2019): @FilipBB: There are some workarounds: 1. Pipe the command output into a text file, open the text file in a Windows editor to copy its contents. 2. Copy the tmux (or screen or whatever terminal multiplexer is used) buffer into clipboard using a shortcut/built-in command.
Author
Owner

@FilipBB commented on GitHub (Jul 31, 2019):

Thanks, unfortunately it's a little cumbersome for remote work, you'd have to copy the file back to your local machine, and I can't get tmux buffer copy on the remote side to work. Hopefully this issue gets fixed in the near future.

@FilipBB commented on GitHub (Jul 31, 2019): Thanks, unfortunately it's a little cumbersome for remote work, you'd have to copy the file back to your local machine, and I can't get tmux buffer copy on the remote side to work. Hopefully this issue gets fixed in the near future.
Author
Owner

@CzBiX commented on GitHub (Sep 4, 2019):

Is there any plan to fix it?

@CzBiX commented on GitHub (Sep 4, 2019): Is there any plan to fix it?
Author
Owner

@zadjii-msft commented on GitHub (Sep 4, 2019):

Looks like this bug fell under the radar.

@strarsis are you holding shift while you're copying (via right click)? In conhost, when the user holds shift while copying, we won't "trim whitespace", leaving the space at the end of the line as part of the copied text. This also applies to using ctrl+shift+c for copying from conhost.

Additionally, what are you pasting into? Notepad, or some other commandline application running in the console?

Also cc'ing @carlos-zamora

@zadjii-msft commented on GitHub (Sep 4, 2019): Looks like this bug fell under the radar. @strarsis are you holding shift while you're copying (via right click)? In conhost, when the user holds shift while copying, we won't "trim whitespace", leaving the space at the end of the line as part of the copied text. This also applies to using <kbd>ctrl+shift+c</kbd> for copying from conhost. Additionally, what are you pasting into? Notepad, or some other commandline application running in the console? Also cc'ing @carlos-zamora
Author
Owner

@CzBiX commented on GitHub (Sep 4, 2019):

Just left click and drag to select multiline text, then right click to copy, then Ctrl+V to paste in notepad will get single line text include a lots of space without newline.

And paste to another place will get the same result.
But the same operations works well in the original WSL terminal without issue.

example result:

server {                                                                                                                  listen 443 ssl http2;                                                                                                   server_name example.com;                                                                                                                                                                                                                   include snippets/log.conf;                                                                                              include snippets/auth.conf;                                                                                                                                                                                                                     location / {                                                                                                              include proxy_params;                                                                                                   proxy_pass http://10.8.1.1:8888;                                                                                      }                                                                                                                     }
@CzBiX commented on GitHub (Sep 4, 2019): Just left click and drag to select multiline text, then right click to copy, then Ctrl+V to paste in notepad will get single line text include a lots of space without newline. And paste to another place will get the same result. But the same operations works well in the original WSL terminal without issue. example result: ``` server { listen 443 ssl http2; server_name example.com; include snippets/log.conf; include snippets/auth.conf; location / { include proxy_params; proxy_pass http://10.8.1.1:8888; } } ```
Author
Owner

@strarsis commented on GitHub (Sep 4, 2019):

@zadjii-msft: Damn, I have indeed holding down the shift key down while right clicking (for copying).
I need to hold down the shift key for the initial multiline text selection, but when I right click I have to release the Shift key first.

@strarsis commented on GitHub (Sep 4, 2019): @zadjii-msft: Damn, I have indeed holding down the `shift` key down while right clicking (for copying). I need to hold down the `shift` key for the initial multiline text selection, but when I right click I have to release the `Shift` key first.
Author
Owner

@CoskunSunali commented on GitHub (Oct 5, 2019):

I have the copyOnSelect feature enabled so I don't have the shift key pressed at any given time. Following are the results from copying text from different profiles. WSL and git bash profiles seem to have problems.

dotnet --info from PS:

PS C:\Users\Coskun> dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.0.100
 Commit:    04339c3a26

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18362
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.0.100\

Host (useful for support):
  Version: 3.0.0
  Commit:  7d57652f33

.NET Core SDKs installed:
  2.2.402 [C:\Program Files\dotnet\sdk]
  3.0.100 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

dotnet --info from cmd:

C:\Users\Coskun>dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.0.100
 Commit:    04339c3a26

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18362
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.0.100\

Host (useful for support):
  Version: 3.0.0
  Commit:  7d57652f33

.NET Core SDKs installed:
  2.2.402 [C:\Program Files\dotnet\sdk]
  3.0.100 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

dotnet --info from git bash:

Coskun@CS:~ $ dotnet --info                                                                                             .NET Core SDK (reflecting any global.json):                                                                              Version:   3.0.100                                                                                                      Commit:    04339c3a26                                                                                                                                                                                                                          Runtime Environment:                                                                                                     OS Name:     Windows                                                                                                    OS Version:  10.0.18362                                                                                                 OS Platform: Windows                                                                                                    RID:         win10-x64                                                                                                  Base Path:   C:\Program Files\dotnet\sdk\3.0.100\                                                                                                                                                                                              Host (useful for support):                                                                                                Version: 3.0.0                                                                                                          Commit:  7d57652f33                                                                                                                                                                                                                           .NET Core SDKs installed:                                                                                                 2.2.402 [C:\Program Files\dotnet\sdk]                                                                                   3.0.100 [C:\Program Files\dotnet\sdk]                                                                                                                                                                                                         .NET Core runtimes installed:                                                                                             Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]                               Microsoft.AspNetCore.All 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]                                Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]                               Microsoft.AspNetCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]                                Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]                                Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]                                     Microsoft.NETCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]                                      Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]                                      Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]                                                                                                                                              To install additional .NET Core runtimes or SDKs:                                                                         https://aka.ms/dotnet-download

lsb_release -a from WSL:

coskun@CS:~$ lsb_release -a                                                                                             No LSB modules are available.                                                                                           Distributor ID: Ubuntu                                                                                                  Description:    Ubuntu 19.04                                                                                            Release:        19.04                                                                                                   Codename:       disco
@CoskunSunali commented on GitHub (Oct 5, 2019): I have the `copyOnSelect` feature enabled so I don't have the `shift` key pressed at any given time. Following are the results from copying text from different profiles. WSL and git bash profiles seem to have problems. `dotnet --info` from PS: ```ps PS C:\Users\Coskun> dotnet --info .NET Core SDK (reflecting any global.json): Version: 3.0.100 Commit: 04339c3a26 Runtime Environment: OS Name: Windows OS Version: 10.0.18362 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.0.100\ Host (useful for support): Version: 3.0.0 Commit: 7d57652f33 .NET Core SDKs installed: 2.2.402 [C:\Program Files\dotnet\sdk] 3.0.100 [C:\Program Files\dotnet\sdk] .NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download ``` `dotnet --info` from cmd: ```cmd C:\Users\Coskun>dotnet --info .NET Core SDK (reflecting any global.json): Version: 3.0.100 Commit: 04339c3a26 Runtime Environment: OS Name: Windows OS Version: 10.0.18362 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.0.100\ Host (useful for support): Version: 3.0.0 Commit: 7d57652f33 .NET Core SDKs installed: 2.2.402 [C:\Program Files\dotnet\sdk] 3.0.100 [C:\Program Files\dotnet\sdk] .NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download ``` `dotnet --info` from git bash: ```bash Coskun@CS:~ $ dotnet --info .NET Core SDK (reflecting any global.json): Version: 3.0.100 Commit: 04339c3a26 Runtime Environment: OS Name: Windows OS Version: 10.0.18362 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.0.100\ Host (useful for support): Version: 3.0.0 Commit: 7d57652f33 .NET Core SDKs installed: 2.2.402 [C:\Program Files\dotnet\sdk] 3.0.100 [C:\Program Files\dotnet\sdk] .NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download ``` `lsb_release -a` from WSL: ```sh coskun@CS:~$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 19.04 Release: 19.04 Codename: disco ```
Author
Owner

@gitfool commented on GitHub (Oct 5, 2019):

I have copyOnSelect disabled, using mouse right-click for copy paste, not holding shift key.

  • dotnet --info output in cmd and PowerShell pastes correctly into VS Code
  • dir output in cmd and PowerShell pastes incorrectly into VS Code
    • trailing whitespace, no newlines; same issue as with WSL

This makes copy paste from Microsoft Terminal useless.

@gitfool commented on GitHub (Oct 5, 2019): I have `copyOnSelect` disabled, using mouse right-click for copy paste, not holding shift key. - `dotnet --info` output in cmd and PowerShell pastes correctly into VS Code - `dir` output in cmd and PowerShell pastes incorrectly into VS Code - trailing whitespace, no newlines; same issue as with WSL This makes copy paste from Microsoft Terminal useless.
Author
Owner

@hteibler commented on GitHub (Oct 11, 2019):

still not working properly in Version: 0.5.2762.0
copying a text from WSL console when using scroll-back is loosing CR or LF

@hteibler commented on GitHub (Oct 11, 2019): still not working properly in Version: 0.5.2762.0 copying a text from WSL console when using scroll-back is loosing CR or LF
Author
Owner

@giggio commented on GitHub (Nov 27, 2019):

Copying with Ctrl+Shift+C will result in a single line in either PowerShell or WSL.

Copying with right click will not result a single line in either WDL or PowerShell.

Tested on the latest version on master and on the latest from the store (0.7).

@giggio commented on GitHub (Nov 27, 2019): Copying with <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>C</kbd> will result in a single line in either PowerShell or WSL. Copying with right click will not result a single line in either WDL or PowerShell. Tested on the latest version on master and on the latest from the store (0.7).
Author
Owner

@adamncasey commented on GitHub (Apr 23, 2020):

It seems the text is copied as a table instead of text with new line characters. Pasting into something like MS Excel and copying back out again to my text editor produces the expected result.

@adamncasey commented on GitHub (Apr 23, 2020): It seems the text is copied as a table instead of text with new line characters. Pasting into something like MS Excel and copying back out again to my text editor produces the expected result.
Author
Owner

@jan-glx commented on GitHub (Apr 28, 2020):

For me, copying from Windows terminal - WSL - ssh - tmux to Windows with correct white spaces works (only) by:
select text with the mouse while holding shift and copy with Ctrl+ Insert

@jan-glx commented on GitHub (Apr 28, 2020): For me, copying from Windows terminal - WSL - ssh - tmux to Windows with correct white spaces works (only) by: select text with the mouse while holding <kbd>shift</kbd> and copy with <kbd>Ctrl</kbd>+ <kbd>Insert</kbd>
Author
Owner

@fendis0709 commented on GitHub (Nov 2, 2020):

Same issue happens to me.
I can Copy - Paste from WSL Terminal, but when Paste, it doesn't has new line.
It's just inline text. No new line.
Any update on this issue? Is there any work around so I can copy - paste with new line (not inline)?
image

P.S:
I have enough experience using Linux and currently moving to Windows. I have habit of using Ctrl + Shift + C for Copy and Ctrl + Shift + V for Paste.

@fendis0709 commented on GitHub (Nov 2, 2020): Same issue happens to me. I can Copy - Paste from WSL Terminal, but when Paste, it doesn't has new line. It's just inline text. No new line. Any update on this issue? Is there any work around so I can copy - paste with new line (not inline)? ![image](https://user-images.githubusercontent.com/16249274/97895807-d73e8300-1d66-11eb-9248-6fa1fadcc2c9.png) P.S: I have enough experience using Linux and currently moving to Windows. I have habit of using `Ctrl + Shift + C` for Copy and `Ctrl + Shift + V` for Paste.
Author
Owner

@strarsis commented on GitHub (Nov 2, 2020):

@fendis0709: Right, currently one has to just drag and select the text, while not holding the Shift key to avoid this line endings issue.

@strarsis commented on GitHub (Nov 2, 2020): @fendis0709: Right, currently one has to just drag and select the text, while _not_ holding the Shift key to avoid this line endings issue.
Author
Owner

@lukeschlather commented on GitHub (Dec 18, 2020):

So, is there an intention to fix this or is using ctrl-shift-c for copy functioning as designed? Because this is annoying.

@lukeschlather commented on GitHub (Dec 18, 2020): So, is there an intention to fix this or is using ctrl-shift-c for copy functioning as designed? Because this is annoying.
Author
Owner

@Don-Vito commented on GitHub (Dec 23, 2020):

@lukeschlather - not sure if addresses your needs, but the behavior of copy is configurable (see here: https://docs.microsoft.com/en-us/windows/terminal/customize-settings/actions#copy).
Among the settings, you can decide where the new lines should be preserved or not.

@Don-Vito commented on GitHub (Dec 23, 2020): @lukeschlather - not sure if addresses your needs, but the behavior of copy is configurable (see here: https://docs.microsoft.com/en-us/windows/terminal/customize-settings/actions#copy). Among the settings, you can decide where the new lines should be preserved or not.
Author
Owner

@lukeschlather commented on GitHub (Dec 23, 2020):

@Don-Vito where is the settings.json file located? The docs are somewhat vague.

Regardless, stripping newlines when copying seems like a bad default. Is that even a feature people want?

@lukeschlather commented on GitHub (Dec 23, 2020): @Don-Vito where is the settings.json file located? The docs are somewhat vague. Regardless, stripping newlines when copying seems like a bad default. Is that even a feature people want?
Author
Owner

@DHowett commented on GitHub (Dec 23, 2020):

by default

if we are doing that by default, it is a bug.

@DHowett commented on GitHub (Dec 23, 2020): > by default if we are doing that by default, it is a bug.
Author
Owner

@lukeschlather commented on GitHub (Dec 23, 2020):

Isn't that what this bug is? I just installed WSL2 Ubuntu for the first time and I am seeing this bug. Which has been open for two years and seems like it ought to be a fairly straightforward fix.

@lukeschlather commented on GitHub (Dec 23, 2020): Isn't that what this bug is? I just installed WSL2 Ubuntu for the first time and I am seeing this bug. Which has been open for two years and seems like it ought to be a fairly straightforward fix.
Author
Owner

@DHowett commented on GitHub (Dec 23, 2020):

You’d be surprised. There’s a lot of factors here- our shared code with the traditional windows console, its support for line wrapping, it supporting different modes of newline deferral (which directly impact wrapping behavior), and users using prompts that extend to the right column of the screen making us think that the text has wrapped. Nobody on the team hits this with any regularity, and that makes it hard to track down.

@DHowett commented on GitHub (Dec 23, 2020): You’d be surprised. There’s a lot of factors here- our shared code with the traditional windows console, its support for line wrapping, it supporting different modes of newline deferral (which directly impact wrapping behavior), and users using prompts that extend to the right column of the screen making us think that the text has wrapped. Nobody on the team hits this with any regularity, and that makes it hard to track down.
Author
Owner

@DHowett commented on GitHub (Dec 23, 2020):

There’s a bug in our tracker that mentions “exact wrap”; this is another likely source of issues here. At its heart, this is a misdetection of an application’s intent to wrap or not.

@DHowett commented on GitHub (Dec 23, 2020): There’s a bug in our tracker that mentions “exact wrap”; this is another likely source of issues here. At its heart, this is a misdetection of an application’s intent to wrap or not.
Author
Owner

@lukeschlather commented on GitHub (Dec 24, 2020):

That makes sense. I was reacting to the suggestion that this is a configurable option that was set this way by design. It seems everyone agrees that not copying newlines here is a bug that should be fixed, even if the fix is not obvious.

@lukeschlather commented on GitHub (Dec 24, 2020): That makes sense. I was reacting to the suggestion that this is a configurable option that was set this way by design. It seems everyone agrees that not copying newlines here is a bug that should be fixed, even if the fix is not obvious.
Author
Owner

@JeremyCCHsu commented on GitHub (Apr 26, 2021):

I encounter the same when I was working with a remote Ubuntu machine. I found a workaround:
Although direct pasting (ctrl+shift+v or shift+right_click) resulted in a single line, send a signal before pasting somehow works:

tmux

ctrl+B then ctrl+v
tmux

VS Code terminal

ctrl+v then ctrl+shift+v
vscode

The text I copied is the following

# empty line 
from pathlib import Path
import numpy as np
x = np.zeros([3, 2])  
 
  

The leading and the trailing empty line(s) are necessary. (The two trailing lines are empty instead of a space, but I have to put a space there for Markdown to display them. Note that when the pasted content is a single-line, it gets white backgrounds.)

Not sure whether the above is useful, but this has become my workaround recently...

@JeremyCCHsu commented on GitHub (Apr 26, 2021): I encounter the same when I was working with a remote Ubuntu machine. I found a workaround: Although direct pasting (ctrl+shift+v or shift+right_click) resulted in a single line, send a **signal** before pasting somehow works: ## tmux `ctrl+B` then `ctrl+v` ![tmux](https://user-images.githubusercontent.com/16027371/116058635-9d658e00-a6b2-11eb-9644-b415188fcc75.png) ## VS Code terminal `ctrl+v` then `ctrl+shift+v` ![vscode](https://user-images.githubusercontent.com/16027371/116058665-a5253280-a6b2-11eb-8142-ec7ae391e831.png) The text I copied is the following ```python # empty line from pathlib import Path import numpy as np x = np.zeros([3, 2]) ``` **The leading and the trailing empty line(s) are necessary.** (The two trailing lines are empty instead of a space, but I have to put a space there for Markdown to display them. Note that when the pasted content is a single-line, it gets white backgrounds.) Not sure whether the above is useful, but this has become my workaround recently...
Author
Owner

@wpater commented on GitHub (Apr 27, 2021):

Try to copy text with ctrl c instead of ctrl shift c.

@wpater commented on GitHub (Apr 27, 2021): Try to copy text with `ctrl c` instead of `ctrl shift c`.
Author
Owner

@dyipon commented on GitHub (Jul 2, 2021):

Same issues with mcview :/

@dyipon commented on GitHub (Jul 2, 2021): Same issues with mcview :/
Author
Owner

@joeycumines commented on GitHub (Jul 27, 2021):

Thanks @wpater, ctrl+c worked....

Why does it work if ctrl+shift+c doesn't, though?

@joeycumines commented on GitHub (Jul 27, 2021): Thanks @wpater, ctrl+c worked.... Why does it work if ctrl+shift+c doesn't, though?
Author
Owner

@wpater commented on GitHub (Aug 5, 2021):

@joeycumines

Thanks @wpater, ctrl+c worked....

Why does it work if ctrl+shift+c doesn't, though?

I think that CTRL+SHIFT+C interprets selection as one line. All trailing spaces at the end of visual lines are copied instead of end of line characters.

@wpater commented on GitHub (Aug 5, 2021): @joeycumines > > > Thanks @wpater, ctrl+c worked.... > > Why does it work if ctrl+shift+c doesn't, though? I think that CTRL+SHIFT+C interprets selection as one line. All trailing spaces at the end of visual lines are copied instead of end of line characters.
Author
Owner

@rdeforest commented on GitHub (Oct 17, 2021):

Edit to add: problem is back, so while there may still be a problem with The Nut Behind The Wheel, what I wrote below isn't necessarily valid since I still don't know what combination of settings and either pressing or not pressing shift will magicaly do what I want. I'm quoting my original comment below:

This issue is more-or-less resolved for me in that the problem was The Nut Behind The Wheel, aka PEBCAK.

What had confused me was that copying had been working the way I expected for a while then started working the other way. Until I read this issue I didn't know what I had done to change the copy action behavior. In my case I had mis-understood the setting "Text format when copying". It defaults to something other than "Plain text only" and when I had encountered that setting I assumed I would never want rich text of any kind coming from or going to my terminal, so I changed it. After I read this thread I switched the setting to HTML and I got the behavior I expected: multiple lines pasted as multiple lines.

So for me if there is still a bug it is that the purpose and effect of the aforementioned setting doesn't match reality. I still don't understand what it means for the plain text I copy out of a terminal to be formatted as "Both HTML and RTF". In what sense is the content I'm copying "formatted" when I execute the copy action? Shouldn't formatting be happening at a higher/lower protocol layer, depending on which way you think is up? That is, if I were using some (as far as I know non-existent) WebKit-based terminal program and I selected several lines of output from a command, I wouldn't expect the clipboard to contain <span>command output</span> or command output<br/> unless that was literally the output I had copied.

The behavior we're talking about feels to me a lot like the tool (in this case Windows Terminal) is trying too hard to anticipate users' needs instead of just doing The Simplest Thing That Could Possibly Work and letting us figure out how to do the more complex but less frequently needed things with additional tooling and such. I'm more than a little curious what the use case for the single-line-of-text behavior might be. When would I ever want that?

@rdeforest commented on GitHub (Oct 17, 2021): **Edit to add**: problem is back, so while there may still be a problem with The Nut Behind The Wheel, what I wrote below isn't necessarily valid since I still don't know what combination of settings and either pressing or not pressing `shift` will magicaly do what I want. I'm quoting my original comment below: > This issue is more-or-less resolved for me in that the problem was The Nut Behind The Wheel, aka PEBCAK. > > What had confused me was that copying had been working the way I expected for a while then started working the other way. Until I read this issue I didn't know what I had done to change the copy action behavior. In my case I had mis-understood the setting "Text format when copying". It defaults to something other than "Plain text only" and when I had encountered that setting I assumed **I would never want rich text of any kind coming from or going to my terminal**, so I changed it. After I read this thread I switched the setting to HTML and I got the behavior I expected: **multiple lines pasted as multiple lines**. > > So for me if there is still a bug it is that the purpose and effect of the aforementioned setting doesn't match reality. I still don't understand what it means for the plain text I copy out of a terminal to be formatted as "Both HTML and RTF". In what sense is the content I'm copying "formatted" when I execute the copy action? Shouldn't formatting be happening at a higher/lower protocol layer, depending on which way you think is up? That is, if I were using some (as far as I know non-existent) WebKit-based terminal program and I selected several lines of output from a command, I wouldn't expect the clipboard to contain `<span>command output</span>` or `command output<br/>` unless that was literally the output I had copied. > > The behavior we're talking about feels to me a lot like the tool (in this case Windows Terminal) is trying too hard to anticipate users' needs instead of just doing The Simplest Thing That Could Possibly Work and letting us figure out how to do the more complex but less frequently needed things with additional tooling and such. I'm more than a little curious what the use case for the single-line-of-text behavior might be. When would I ever want that?
Author
Owner

@seldomworks commented on GitHub (Oct 22, 2021):

Edit to add: problem is back, so while

I agree, the problem is back. Or in my case, I have only noticed it for the first time this week. Something does seem to have broken recently. I see the problem both in windows terminal and windows terminal preview.

@seldomworks commented on GitHub (Oct 22, 2021): > **Edit to add**: problem is back, so while I agree, the problem is back. Or in my case, I have only noticed it for the first time this week. Something does seem to have broken recently. I see the problem both in windows terminal and windows terminal preview.
Author
Owner

@rdeforest commented on GitHub (Oct 27, 2021):

I've found some useful things:

  1. if my selection ends after the last non-whitespace on the last line, the selection is copied as a single line
  2. Once I've done that, every selection is single-line until I resize the window

Notably, I'm in X11-selection mode where it automatically copies when I select the text. I don't have to press ctrl-c or ctrl-shift-c. I like it that way.

@rdeforest commented on GitHub (Oct 27, 2021): I've found some useful things: 1. if my selection ends after the last non-whitespace on the last line, the selection is copied as a single line 1. Once I've done that, every selection is single-line until I resize the window Notably, I'm in X11-selection mode where it automatically copies when I select the text. I don't have to press ctrl-c or ctrl-shift-c. I like it that way.
Author
Owner

@zadjii-msft commented on GitHub (Nov 23, 2021):

Hey so, this issue's been open for a WHILE now and has drifted in root cause over the years.

Part of this is some unintentional confusion that's definitely my fault. Then the propsheet says "Use Ctrl+Shift+C/V as copy/paste", that was written erroneously. At the time I added that, I actually just added support for Ctrl+Shift+V paste, because it seemed to me that Ctrl+Shift+C for copy seemingly always worked. Turns out, yes, it did always work, with the caveat: Ctrl+Shift+C to copy in the vintage console copies as a single line. I'm not sure when that was added, probably before my tenure here.

So really, that checkbox should say "Use Ctrl+Shift+V as paste". #174 is here for tracking either changing that text, or changing that behavior in conhost. Neither we're particularly inclined to do, since we're largely only focusing on UX enhancements for the Terminal at this point.

In general, to help avoid this, DONT USE Ctrl+Shift+C TO COPY FROM CONHOST.

The Console handles copy-pasting just terribly, and we've done a lot of things better with the Terminal. Including things like allowing Ctrl+C to copy a selection, but not send a ^C when there's a selection. Not to forget, the keybindings are entirely customizable.

At this point, this thread is full of folks on different versions, with unclear reports of how they've got the console & terminal configured, and how they're precisely copying, and the thread isn't really discretely actionable. If you're still having trouble, it's probably best to open a new thread.

@zadjii-msft commented on GitHub (Nov 23, 2021): Hey so, this issue's been open for a WHILE now and has drifted in root cause over the years. Part of this is some unintentional confusion that's definitely _my_ fault. Then the propsheet says "Use Ctrl+Shift+C/V as copy/paste", that was written erroneously. At the time I added that, I actually just added support for `Ctrl+Shift+V` paste, because it seemed to me that `Ctrl+Shift+C` for copy seemingly _always worked_. Turns out, yes, it did always work, with the caveat: `Ctrl+Shift+C` to copy in the vintage console copies **as a single line**. I'm not sure when that was added, probably before my tenure here. So really, that checkbox should say "Use Ctrl+Shift+V as paste". #174 is here for tracking either changing that text, or changing that behavior in conhost. Neither we're particularly inclined to do, since we're largely only focusing on UX enhancements for the Terminal at this point. In general, to help avoid this, **DONT USE `Ctrl+Shift+C` TO COPY FROM CONHOST**. The Console handles copy-pasting just terribly, and we've done a lot of things better with the Terminal. Including things like allowing `Ctrl+C` to copy a selection, but not send a `^C` when there's a selection. Not to forget, the keybindings are entirely customizable. At this point, this thread is full of folks on different versions, with unclear reports of how they've got the console & terminal configured, and how they're precisely copying, and the thread isn't really discretely actionable. If you're still having trouble, it's probably best to open a new thread.
Author
Owner

@ultranaco commented on GitHub (Apr 9, 2022):

You can copy stdout with clip.exe triming new line using the following instructions

Append alias into .bash_aliases
echo "alias clip='tr -d '\''\n'\'' | clip.exe'" >> ~/.bash_aliases

Restart your shell
bash

Enjoy your new clip command with pipe
pwd | clip

Paste
Ctrl + V

@ultranaco commented on GitHub (Apr 9, 2022): You can copy stdout with clip.exe triming new line using the following instructions Append alias into .bash_aliases `echo "alias clip='tr -d '\''\n'\'' | clip.exe'" >> ~/.bash_aliases` Restart your shell `bash` Enjoy your new clip command with pipe `pwd | clip` Paste `Ctrl + V`
Author
Owner

@tms320 commented on GitHub (Dec 14, 2024):

I run command 'wsl -l -v' from pyhton script and trying to split it's output to strings.
And this is a problem.
Console output (if I run 'wsl' manually in Windows terminal) looks fine:
Image
But there is no new line symbols in real output. In python script I get this bytes:
Image
So parsing the output is difficult.

@tms320 commented on GitHub (Dec 14, 2024): I run command 'wsl -l -v' from pyhton script and trying to split it's output to strings. And this is a problem. Console output (if I run 'wsl' manually in Windows terminal) looks fine: ![Image](https://github.com/user-attachments/assets/3f5ce8de-bb0b-481f-b46a-ad248508c353) But there is no new line symbols in real output. In python script I get this bytes: ![Image](https://github.com/user-attachments/assets/8968c15d-458e-43af-bd15-8c672ff3f21f) So parsing the output is difficult.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#55