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

5,757

Solution 1

There does not appear to be any solution to this.

Solution 2

As I mentioned on the OS X version of this question, pasting tabs works fine. But copying them in the first place is tricky on Linux.

Share:
5,757

Related videos on Youtube

WestCoastProjects
Author by

WestCoastProjects

R/python/javascript recently and before that Scala/Spark. Machine learning and data pipelines apps.

Updated on September 18, 2022

Comments

  • WestCoastProjects
    WestCoastProjects over 1 year

    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.

  • WestCoastProjects
    WestCoastProjects almost 11 years
    I neglected to mention the problem focuses on tab characters getting lost.
  • terdon
    terdon almost 11 years
    @javadba selecting and middle clicking should copy tabs across correctly. In fact all of them should.
  • WestCoastProjects
    WestCoastProjects almost 11 years
    Tabs definitely get lost with control c: pls test yourself - does "middle click" keep the tabs? i have 2 button mouse only
  • terdon
    terdon almost 11 years
    @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.
  • WestCoastProjects
    WestCoastProjects almost 10 years
    (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.
  • mivk
    mivk almost 6 years
    @terdon: No, middle-click doesn't work either. Tabs disappear from the pasted text. At least with gnome-terminal.
  • terdon
    terdon almost 6 years
    @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
    terdon almost 6 years
    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?
  • WestCoastProjects
    WestCoastProjects almost 6 years
    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 ..
  • terdon
    terdon almost 6 years
    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.
  • mivk
    mivk almost 6 years
    @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.