Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cant copy a tab character from terminal

Tags:

terminal

I'm writing a small program that prints to the terminal its output in tab separated format. But whenever I select the text with tabs and copy it, the tabs are replaces with some number of spaces.

What can I do to make terminal not replace tabs with spaces when trying to copy?

like image 473
Kurru Avatar asked Mar 30 '13 23:03

Kurru


2 Answers

On macOS Sierra (maybe also in earlier versions), you can do:

Edit -> Copy Special -> Copy Plain Text

Or using the shortcut: alt+shift+⌘ cmd+C

like image 163
elste Avatar answered Oct 23 '22 22:10

elste


Your best bet may be to substitute "\t" in place of tabs in your output, and do a search and replace after you copy and paste it to the destination. You could use any character or string as the substitute, of course, but using "\t" makes it easy to restore the tabs using echo -e if pasting to a command-line environment. The substitution can be done using: |sed 's/\\/\\\\\\/g;s/\t/\\t/g'

like image 25
Alex Stern Avatar answered Oct 23 '22 22:10

Alex Stern



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!