Results 1 to 6 of 6

Thread: Tab lost in copy/paste into terminal

  1. #1
    Join Date
    Apr 2019
    Beans
    3

    Tab lost in copy/paste into terminal

    I am unable to copy and paste a tab from eg gedit, calc , writer into a terminal (gnome terminal or terminator). The tab just disappears, eg "Asdf jkl" becomes "Asdfjk". Spaces are not lost. Strangely, tabs are not lost when copying from one terminal window to another. I believe that this is a new behaviour in the last few weeks possibly due to a recent update since I never noticed it before. I am running Ubuntu 16.04.6 LTS. This is a big problem since it can create garbage when copy pasting.
    Thanks for any assistance.

  2. #2
    Join Date
    Aug 2011
    Location
    51.8° N 5.8° E
    Beans
    5,479
    Distro
    Xubuntu 20.04 Focal Fossa

    Re: Tab lost in copy/paste into terminal

    When you type or paste a tab at the command line, the shell attempts to complete a filename. It doesn't matter whether you type or paste it, two different things to the terminal, just the same for the shell. For example, when I paste Down<tab>foo on my command line, it gets expanded to Downloads/foo, as Downloads/ is the only file/directory starting with Down. I would be surprised if it hadn't worked like that for decades. If filename expansion fails, the tab just disappears.

    You can type a tab in the terminal, just not at the command line.

    You write you can copy a tab from one terminal to another. How do you get a tab in that first terminal?
    Last edited by Impavidus; May 1st, 2019 at 08:53 AM. Reason: fixed partial sentence

  3. #3
    Join Date
    Apr 2008
    Location
    Norwich CT
    Beans
    2,661
    Distro
    Ubuntu Mate

    Re: Tab lost in copy/paste into terminal

    Also, you can highlight text and paste it by clicking the middle mouse button. Along with directory completion with TAB, one of the superior things about Linux.

    I drink my Ubuntu black, no sugar.
    Ubuntu user 28819

  4. #4
    Join Date
    Dec 2014
    Beans
    1,608

    Re: Tab lost in copy/paste into terminal

    I don't think it's the terminal swallowing the tab-characters, it's the shell. When I paste into nano in a terminal, the tabs get pasted, if I paste into the shell they get lost. Since the tab has a function in an interactive shell (auto-completion), that's not all that surprising. You can't enter a tab in bash without hitting 'ctrl-v' ('use next character verbatim') before it. If you examine the characters pasted from one terminal to another, you will probably find that the tab has been converted to multiple spaces.

    Holger

    Edit: Damn, ninja'd twice ...

  5. #5
    Join Date
    Apr 2019
    Beans
    3

    Re: Tab lost in copy/paste into terminal

    Thanks, that is very informative. I inserted a tab into the terminal using control v control i. I was incorrect about the tab being maintained, it appears that it is converted to four spaces that looked like a tab.

  6. #6
    Join Date
    Apr 2019
    Beans
    3

    Re: Tab lost in copy/paste into terminal

    Two more quick points...
    Using the middle mouse button does not affect the auto-completion, the tab is still lost.
    The auto-completion can be turned off for the terminal session by entering
    bind 'set disable-completion on'
    and then the tab gets pasted properly and is retained. The auto-completion can then be reverted back by entering
    bind 'set disable-completion off'
    and then the tab is again lost, and you get auto-completion back.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •