11
3
When I copy and paste text using the X11 mouse selection between two terminal windows, tabs are often, but not always, converted to spaces. This appears to depend on the involved terminal applications and the programs running inside them.
This is what I've found out by experimentation:
- It depends solely on what's running on the source (copy) side. The target (paste) side will paste tabs no matter what is running, if the source preserved them.
- Only
gnome-terminal
on the source side preserves tabs.xterm
andkonsole
do not. - Tabs are only preserved if the file has been output using
cat
. Other applications such asless
,vim
,emacs
, ornano
don't preserve tabs.
What is the explanation for this? Are these bugs in konsole
and xterm
, or can they be configured differently? Can less
and such be configured to preserve tabs in output?
It's worth noting that in Roff (
troff
&nroff
), tabstops can be set independently of each other, much like the "ruler" toolbars in modern word processors (OpenOffice, Microsoft Word, et al). Manpages rarely use custom tab-stops in practice, however. – None – 2018-07-12T05:56:25.370mandoc(1)
also allows users to override the default indentation width from command-line, using-O indent=N
(defaults to 5 columns). – None – 2018-07-12T06:00:54.2232
less -xn
configures it to use n spaces rather than a tab character.-U
makes it display tab as^I
. I haven't found a way to make it emit a literal tab character so that copying the text will paste a tab character, but I'd love to know how. – Matt McClure – 2013-06-04T10:43:50.750