8
$ cat test.txt
a
b
$ xclip test.txt

Pasting the content in an email in Thunderbird will result in

a b

Any idea why?

I'm running Arch Linux (64-bit) and I paste the code via a mouse wheel click (though I also tried CTRL+V without having any luck).

Pasting something for example in Libreoffice keeps the new line characters. I have no idea why it does not work in Thunderbird. I also tried Windows convention line breaks and it still was not correct in Thunderbird.

  • Please provide more information: e.g., what operating system you're running, and what you're doing that results in the (undesired) a b output. Is this a mouse action or a keyboard shortcut (e.g., Ctrl+V), or are you talking about running xclip to paste the clipboard? Are you using a command like echo `xclip` or echo $(xclip)? If you are, try adding quotes: echo "$(xclip)". – G-Man Says 'Reinstate Monica' Oct 24 '14 at 20:43
  • @don_crissti unfortunately the command did not work. – user2820379 Oct 24 '14 at 20:57
  • @G-Man I edit my question and included the information you requested. Adding quotes did not work unfortunately. – user2820379 Oct 24 '14 at 21:01

1 Answers1

2

From what I tried, it seems that I can not reproduce your issue of joining short lines. The text gets pasted or inserted always with the newlines.
Pasting the clipboard with Ctrl-V works, pasting the selection with the middle mouse button works too.

But your actual problem to solve may* be to paste a section of text as a citation, keeping the line formating.

To handle that case, there is a secial variant of pastin in thunderbird to do just that: In the "Edit" menu, or the context menu, there is "Paste as Quotation". That pastes lines prefixed with >, and leaves the line breaks alone.

The text pasted is the content of the clipboard. In X, there are multiple buffers for cut and paste. Normally only two, "clipboard" and "primary" are used.

Your command

xclip test.txt

Puts the content of test.txt into the "primary". If you want to directly paste it as quotation, you can modify the command to put the text into the clipboard:

xclip -selection clipboard test.txt



*) It's an interpretation of the question and may be not the case - I see that the question is technically asking why the new lines are lost, not how to change that.

Volker Siegel
  • 17,283
  • I seem to have two clipboard buffers. One that I can access using Ctrl-V/Ctrl-C and one that I can access by just selecting some text (which copies the selection) and by pressing the mouse wheel (pasting). The paste as quotation option seems to access the Ctrl-V/Ctrl-C buffer which is the "wrong" buffer since xclip copies into the other buffer. Did you try it with xclip and it worked for you? – user2820379 Apr 27 '15 at 08:06
  • Yes, sure - the clipboard is sparate from the selection in X. (There are even more buffers, normally not used) There are some words on it in the man page of xclip. – Volker Siegel Apr 27 '15 at 08:12
  • Yes, I used xclip - seems what you want to use is xclip -selection clipboard test.txt? (Side note: do not call files test - it will bite you one day... (because of confusion with the shell builtin test)) – Volker Siegel Apr 27 '15 at 08:13
  • 1
    Related: http://superuser.com/questions/200444/why-do-we-have-3-types-of-x-selections-in-linux http://unix.stackexchange.com/questions/84246/how-many-clipboards-are-in-system http://unix.stackexchange.com/questions/69111/how-to-target-multiple-selections-with-xclip (Don't even try to understand the full picture of the X clipboards - it's a can of worms) – Volker Siegel Apr 27 '15 at 08:19
  • I tried the command xclip -selection clipboard test.txt and it indeed copied into the Ctrl-V/Ctrl-C buffer but the problem remains the same. The line breaks get lost both when using Ctrl-V and when using "paste as quotation". This is very strange. Again if I paste into libreoffice for example it works. – user2820379 Apr 27 '15 at 20:24
  • Ok, now it get's interesting ;) Are you writing the mail in html format or similar? Can you add a screenshot of the mail edit window? – Volker Siegel Apr 27 '15 at 20:33
  • @user2820379 I'm wondering it may be related to format=flowed, see section Disabling Format=Flowed when sending messages Maybe you just check those two config keys to make sure it's ruled out? – Volker Siegel Apr 27 '15 at 20:37
  • Wow. I indeed was using html. Turning this off solved the problem. What could be an explanation for that? – user2820379 Apr 28 '15 at 08:18
  • Explanation? "Thunderbird, a software that has evolved over more than a decade to follow changes in protocols and UI expectations. Under these circumstances, it is inevitable that the structure degrades - know as bit rot. In this context, it is hard to introduce a new feature in conflict with the current state, when solving the conflict is infeasible. A new UI feature like HTML editing may need to be sneaked in between rotten skeletons of old protocol layers. It will work nicely, but as a result, you will find the configuration of the new feature down between these old rotten sediments." – Volker Siegel Apr 28 '15 at 15:30
  • Actually, I started that sentence as a joke - but it came out as not that meaningless (except that I had to shorted it to half to fit it into the comment). Maybe I make it a real answer - want to ask the question? – Volker Siegel Apr 28 '15 at 15:31
  • I think I'm fine with the explanation you gave me. Thanks a lot for your help. – user2820379 Apr 30 '15 at 17:22