Terminal: Copy and paste in bash generates one single line

Created on 7 Aug 2019  路  17Comments  路  Source: microsoft/terminal

Environment

Windows build number: Microsoft Windows [Version 10.0.18362.239]
Windows Terminal version (if applicable): Version: 0.3.2171.0

Using bash within Windows terminal.

Steps to reproduce


Copy several text lines and paste them using vi text editor in bash (WSL).

Expected behavior


Properly copied lines within the text editor.

Actual behavior


A single line is generated with spaces so that it looks like they are different lines.

Area-Interaction Issue-Bug Product-Terminal Resolution-Duplicate

Most helpful comment

This is the single most frustrating thing about Terminal that makes it mostly unusable. I can live with the little UI glitches, but this is pure frustration.

All 17 comments

Just to clarify, this happens when copying lines from within a file in vi to the very same file in vi.

If I copy text lines from outside (let's say, Visual Code) to vi, then this is what happens:

Line1

Line2

Line3

I get a jump line in between every line that I am copying.

So, clipboard keybindings copy/paste came in with PR #1093. There's two copy actions copy and copyTextWithoutNewlines. With mouse copy, holding SHIFT differentiates the two. With keyboard copy, these are two separate keybound options.

Given this information...

  • if you try to mouse copy with(out) SHIFT, does that fix the issue?
  • if you try to keyboard copy with one copyTextWithoutNewlines (vs copy), does that fix the issue?

Let me know below. Thanks!

I tried copying with and without shift by using the mouse: same result.
I did the same thing with the keyboard: same result.

This basically renders useless editing text within the terminal in any Linux system : /

Also, copying several lines from outside the terminal creates a jump line in between every line you copy (and it doesn't matter if you use CRLF or only LF).

Having the same issue you select a couple of lines from Windows Terminal, click the right button, go to notepad, do Ctrl-V and everything ends up on one line with spaces in between.

image

I'm having a simular issue, but instead of that everything gets pasted into a single line.. when i paste i get after every line, an extra new line...

After i copy from a file/site or notepad etc. into the terminal with the Ubuntu app configured, i get an extra new line between every line.

When i open the Ubuntu app self, i can paste without any extra new lines.

-- same issue as havidarou. and same result with:
I tried copying with and without shift by using the mouse: same result.
I did the same thing with the keyboard: same result.

Hi, I also mentioned that
there are two kind of behaviors:

  1. Copying from within the terminal -> generates a single line with spaces.
  2. Copying from outside the terminal -> you get an extra line between every line.

When copying from a text editor (ex. vscode) spaces between lines will still be generated even if the file is using LF line endings
image

Copying out of the terminal into a text editor does not add proper newlines as expected
image

On further review it also appears to add all of the whitespace after the content on each line (more space added the wider the terminal is)
image

I am seeing this is not just related to bash. Within Powershell 5, powershell core 6 and 7 running in windows terminal, I am getting very inconsistent copy/paste behavior. Extra whitespace, and missing line endings. The whitespace and (missing)line endings are in different places if i resize the terminal window and re-generate the output and copy/paste once again.

Sometimes all lines of output might be pasted as 1 single line, other times, it may paste 6 lines correctly before it begins to start missing line endings, and running lines together

Reproduced by copying any multi-line output from terminal and pasting it into Notepad++ or vscode

Can confirm this behaviour.

If you paste the output of a table ( with \t and \n )
image
in LibreOffice
all \t and \n are replaced with spaces ???
image

Also can confirm this behavior. It is very inconsistent with utilities like vi. Pasting into nano via the terminal seems to yield better results than vi. Switched over to a raw Powershell console and vi copy and paste works just fine.

This is the single most frustrating thing about Terminal that makes it mostly unusable. I can live with the little UI glitches, but this is pure frustration.

I am also facing the same issues as reported above in thread. I am primarily using powershell core 6 as primary profile in terminal . This inconsistent behaviour renders windows terminal useless for sysadmins. This is one tool which has huge potential as it gives you option for multiple tabs.

When I copy paste from Windows Notepad three lines with data in towords a Ubuntu in WSL, the copy paste buffer adds an extra carriage return to every line.
look at this printscreen and the hexdump on the file with the copy pasted data and you see the double '0a0a' when it should be a single. (running Windows Terminal (Preview) Version: 0.4.2382.0)
copy-paste

This is still happening in 0.5.
From Windows to bash: double jump lines.
From bash to Windows: there are no jump lines every two lines.

/dup #1091

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mrmlnc picture mrmlnc  路  3Comments

ghost picture ghost  路  3Comments

mrmlnc picture mrmlnc  路  3Comments

miniksa picture miniksa  路  3Comments

dev-logan picture dev-logan  路  3Comments