Viewing Tab Separated Values on the Terminal (it doesn't show the tabs)

0

If I have a tab separated values file, and I say cat it, it nicely renders the file for me all lined up properly. Now if I try to copy paste (using my mouse), to another text editor. The tabs become spaces!?

Is there a terminal emulator that renders tabs as literal tabs, and not as spaces?

Here's a test:

echo -e "first"$'\t'"second"$'\t'"third"$'\n'"1"$'\t'"2"$'\t'"3" > tsv.tsv
cat tsv.tsv

Now try to copy and paste to a GUI text editor.

CMCDragonkai

Posted 2016-05-02T12:30:06.667

Reputation: 349

Answers

1

Terminal emulators based on the vte widget (e.g. gnome-terminal) preserve TABs in this case.

Note that it's limited to the simplest usage scenario only, when the TAB character doesn't advance over already existing content.

Most terminal emulators convert it to spaces because for terminals TAB is not a printable character, it is a control sequence that relocates the cursor. E.g. if you TAB over existing characters, those characters remain there and are not wiped out (not replaced by spaces).

egmont

Posted 2016-05-02T12:30:06.667

Reputation: 1 791

Wow. It works. Thanks. Only wish Konsole could do this as well though. – CMCDragonkai – 2016-05-02T14:28:06.247

1

You probably won't find one. In my experience, even the terminals that terminal-emulators are emulating rendered tabs into spaces on display. Certainly you could set tab stops on VT100s, so it was not a hard bound definition of what a tab was on the screen. If you sent the escape sequence to print screen on a real Digital Equipment Corporation VT100, it would send spaces to the printer where tabs had been rendered as spaces.

As an alternate solution, consider opening your tabbed source document in a separate session of your GUI editor. Then select your required text, cut and paste into your target document that you have open in a different session. For instance, I know gvim will copy tab characters into the clipboard.

Whether your particular GUI editor supports it is just a matter of conjecture at this point.

infixed

Posted 2016-05-02T12:30:06.667

Reputation: 759