How to copy/paste tab characters via the Clipboard into terminal session on gnome / ubuntu

3

How do i copy text that includes tab characters from a text editor, let's say gedit into a terminal session on ubuntu/gnome? I am on ubuntu 12.0.4 using gnome classic.

UPDATE This same issue happens in CentOs - basically seems to apply to any gnome.

javadba

Posted 2013-06-13T22:43:53.713

Reputation: 2 201

For OSX: http://superuser.com/questions/687240/how-to-paste-a-tab-into-os-x-terminal-from-clipboard

– Ciro Santilli 新疆改造中心法轮功六四事件 – 2015-06-09T11:04:55.823

Answers

1

There does not appear to be any solution to this.

javadba

Posted 2013-06-13T22:43:53.713

Reputation: 2 201

Hang on, are you trying to paste into the terminal prompt, or into a text file opened in the terminal? If the former, could you explain why you would need that? – terdon – 2018-06-19T10:42:53.840

0

Just select the text you want to copy, and then middle click on the terminal. On most *nix systems, selecting copies and middle click pastes.

Alternatively, you can select => right click=>copy => terminal => right click=> paste

Or, simply Ctrl+C,Ctrl+V

Have a look here for a short explanation of the Linux/Unix clipboard and the X buffer.

terdon

Posted 2013-06-13T22:43:53.713

Reputation: 45 216

(a) clicking both left and right is not working (b) I usually do not have an external mouse anyways and no middle click on trackpad. So in the end I still do not have a solution. I came back here to my own question via googling over a year later. – javadba – 2014-07-25T05:01:08.020

@terdon: No, middle-click doesn't work either. Tabs disappear from the pasted text. At least with gnome-terminal. – mivk – 2018-06-19T10:35:50.983

@mivk I don't understand this. It works fine for me and always has, across at least 5 different Linux distributions. Are you trying to paste the text directly onto the command line? If so, why would you need that? That's the only case where I see this happening and I can't imagine a use case for it. It works as expected if you first run cat > file and then paste, for instance. Feel free to come into /dev/chat and ping me and I'll see if we can find a workaround.

– terdon – 2018-06-19T10:42:07.507

Five years later it's a tad challenging to remember the use case: but at least one of them was pasting into REPL : could be ipython or scala prompt or jruby or .. – javadba – 2018-06-19T14:50:50.907

Fair enough, someone commented on my answer today which is why I brought it up again, and I just realized you were probably trying to paste directly into some sort of prompt, which makes my answer completely irrelevant. My belated apology, I thought you were pasting into the terminal (something like cat > file as I mentioned above). For what it's worth, in ipython you can do it with cpaste. – terdon – 2018-06-19T14:54:16.127

@terdon: yes, I was pasting directly into the command-line, to test a regex before using it on a file. Specifically into echo "Trying-to-paste-in-here" | perl -nle ... etc. In such a case, tabs get removed, and this is how I landed on this question. Not a big deal, but it was disconcerting and I thought there was something wrong with my terminal. – mivk – 2018-06-19T15:53:42.480

I neglected to mention the problem focuses on tab characters getting lost. – javadba – 2013-06-14T14:38:31.910

@javadba selecting and middle clicking should copy tabs across correctly. In fact all of them should. – terdon – 2013-06-14T14:47:04.260

Tabs definitely get lost with control c: pls test yourself - does "middle click" keep the tabs? i have 2 button mouse only – javadba – 2013-06-14T15:00:14.370

@javadba if you have a two button mouse, you can emulate the middle click by clicking both buttons at the same time. I did try it and both Ctrl+V and Middle click copy the tabs correctly on my system. Are you sure you have tabs there? You can check with od -c file.txt. – terdon – 2013-06-14T16:27:31.923