public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Copy converts tabs to spaces ?
@ 2009-02-02 10:06 xerces8
  2009-02-02 10:27 ` Sisyphus
  2009-02-02 13:57 ` Ralf Gans
  0 siblings, 2 replies; 8+ messages in thread
From: xerces8 @ 2009-02-02 10:06 UTC (permalink / raw)
  To: cygwin

Hi!

I noticed that when copying text from a the Cygwin Bash window and then pasting it somewhere (like
WordPad), tabulator characters are converted to spaces.

The same happens with RXVT too.

Details:
 - print the content of some text file that has tabs (like a C program source) : cat foo.c
 - select and copy the text with the mouse
 - paste (ctrl-V) into WordPad

The text in Wordpad has no more tabs.

Is there a way around this ?

Regards,
David



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Copy converts tabs to spaces ?
  2009-02-02 10:06 Copy converts tabs to spaces ? xerces8
@ 2009-02-02 10:27 ` Sisyphus
  2009-02-02 10:42   ` Sisyphus
  2009-02-02 13:57 ` Ralf Gans
  1 sibling, 1 reply; 8+ messages in thread
From: Sisyphus @ 2009-02-02 10:27 UTC (permalink / raw)
  To: xerces8, cygwin


----- Original Message ----- 
From: "xerces8" <xerces8@butn.net>

> Details:
> - print the content of some text file that has tabs (like a C program 
> source) : cat foo.c
> - select and copy the text with the mouse
> - paste (ctrl-V) into WordPad

You'll get the same behaviour if, instead of running 'cat foo.c' in the 
bash/RXVT shell, you start by running 'type foo.c' in the cmd.exe shell.

One workaround is to run 'notepad foo.c' instead of 'cat.c', and then 
copy'n'paste from the instance of foo.c that has been opened in notepad.

Is that a suitable alternative ?

Cheers,
Rob


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Copy converts tabs to spaces ?
  2009-02-02 10:27 ` Sisyphus
@ 2009-02-02 10:42   ` Sisyphus
  0 siblings, 0 replies; 8+ messages in thread
From: Sisyphus @ 2009-02-02 10:42 UTC (permalink / raw)
  To: xerces8, cygwin


----- Original Message ----- 
From: "Sisyphus" <sisyphus1@optusnet.com.au>

> One workaround is to run 'notepad foo.c' instead of 'cat.c'

Hmmm .. doesn't make a lot of sense. I meant "instead of 'cat foo.c'".

Cheers,
Rob

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Copy converts tabs to spaces ?
  2009-02-02 10:06 Copy converts tabs to spaces ? xerces8
  2009-02-02 10:27 ` Sisyphus
@ 2009-02-02 13:57 ` Ralf Gans
  2009-02-02 20:16   ` Buchbinder, Barry (NIH/NIAID) [E]
  1 sibling, 1 reply; 8+ messages in thread
From: Ralf Gans @ 2009-02-02 13:57 UTC (permalink / raw)
  To: xerces8; +Cc: cygwin

Hi,

copy an paste from window to window takes what's printed,
not what you have written.

So, if the terminal prints spaces to represent the tabs,
as a terminal usualy does, you CAN only copy spaces.

All else is an exception, U*X ist NOT wysiwyg!

Regards,

Ralf

On 02.02.2009, at 11:05, xerces8 wrote:

> Hi!
>
> I noticed that when copying text from a the Cygwin Bash window and  
> then pasting it somewhere (like
> WordPad), tabulator characters are converted to spaces.
>
> The same happens with RXVT too.
>
> Details:
> - print the content of some text file that has tabs (like a C  
> program source) : cat foo.c
> - select and copy the text with the mouse
> - paste (ctrl-V) into WordPad
>
> The text in Wordpad has no more tabs.
>
> Is there a way around this ?
>
> Regards,
> David
>
>
>
> --
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
> Problem reports:       http://cygwin.com/problems.html
> Documentation:         http://cygwin.com/docs.html
> FAQ:                   http://cygwin.com/faq/
>
>


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: Copy converts tabs to spaces ?
  2009-02-02 13:57 ` Ralf Gans
@ 2009-02-02 20:16   ` Buchbinder, Barry (NIH/NIAID) [E]
       [not found]     ` <B7021E1A-156E-4F9B-ADFC-B6DE58D5E14D@NSG-GmbH.de>
  0 siblings, 1 reply; 8+ messages in thread
From: Buchbinder, Barry (NIH/NIAID) [E] @ 2009-02-02 20:16 UTC (permalink / raw)
  To: cygwin, 'Ralf Gans'

Ralf Gans wrote on Monday, February 02, 2009 8:57 AM:
> On 02.02.2009, at 11:05, xerces8 wrote:
>> I noticed that when copying text from a the Cygwin Bash window and
>> then pasting it somewhere (like WordPad), tabulator characters are
>> converted to spaces.
>>
>> The same happens with RXVT too.
>>
>> Details:
>> - print the content of some text file that has tabs (like a C
>> program source) : cat foo.c
>> - select and copy the text with the mouse
>> - paste (ctrl-V) into WordPad
>>
>> The text in Wordpad has no more tabs.
>>
>> Is there a way around this ?
>
> copy an paste from window to window takes what's printed, not what
> you have written.
>
> So, if the terminal prints spaces to represent the tabs, as a
> terminal usually does, you CAN only copy spaces.
>
> All else is an exception, U*X ist NOT wysiwyg!

Think about using putclip instead.

  $ cat foo.c | putclip -d
  $ putclip -d < foo.c
  $ putclip --help
  putclip version 0.2.0
    Copy stdin to the Windows Clipboard

  Usage: putclip [OPTION...]

  General options
    -d, --dos         Clipboard text will have DOS line endings.
    -u, --unix        Clipboard text will have UNIX line endings.
    -n, --no-conv     Do not translate line endings.

  Help options
    -?, --help        Show this help message
    --usage           Display brief usage message
    --version         Display version information
    --license         Display licensing information
  NOTE: by default, no line ending conversion is performed.

You also might want to familiarize yourself with getclip.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: Copy converts tabs to spaces ?
       [not found]     ` <B7021E1A-156E-4F9B-ADFC-B6DE58D5E14D@NSG-GmbH.de>
@ 2009-02-07 13:25       ` Buchbinder, Barry (NIH/NIAID) [E]
  2009-02-07 17:24       ` Paul McFerrin
  1 sibling, 0 replies; 8+ messages in thread
From: Buchbinder, Barry (NIH/NIAID) [E] @ 2009-02-07 13:25 UTC (permalink / raw)
  To: cygwin; +Cc: 'Ralf Gans'

> On 02.02.2009, at 21:16, Buchbinder, Barry (NIH/NIAID) [E] wrote:
>> Ralf Gans wrote on Monday, February 02, 2009 8:57 AM:
>>> On 02.02.2009, at 11:05, xerces8 wrote:
>>>> I noticed that when copying text from a the Cygwin Bash window and
>>>> then pasting it somewhere (like WordPad), tabulator characters are
>>>> converted to spaces. 
>>>> 
>>>> The same happens with RXVT too.
>>>> 
>>>> Details:
>>>> - print the content of some text file that has tabs (like a C
>>>> program source) : cat foo.c 
>>>> - select and copy the text with the mouse
>>>> - paste (ctrl-V) into WordPad
>>>> 
>>>> The text in Wordpad has no more tabs.
>>>> 
>>>> Is there a way around this ?
>>> 
>>> copy an paste from window to window takes what's printed, not what
>>> you have written. 
>>> 
>>> So, if the terminal prints spaces to represent the tabs, as a
>>> terminal usually does, you CAN only copy spaces.
>> 
>> Think about using putclip instead.
>> 
>>  $ cat foo.c | putclip -d
>>  $ putclip -d < foo.c
>> 
>> You also might want to familiarize yourself with getclip.

A related trick:

  $ getclip -u | pipe | putclip -d

One might not think of it since the following doesn't work.

  $ cat foo | pipe > foo

In the latter example, the shell opens (and truncates) foo for writing
before cat reads foo.  But it seems that putclip does nothing to the
clipboard until the pipe closes, so getclip is finished before the
clipboard is overwritten.

Also `getclip -u` == $(getclip -u) can sometimes be a convenient way
to provide arguments to a command.

I find getclip and putclip to be real work-savers.  If I have to
do something to multiple chunks of info that has to go through
the Windows clipboard, they let me repeat a pipe by just hitting
the <up-arrow> and <enter>.

Sorry I omitted this from my earlier post.

Enjoy!

- Barry
  Disclaimer: Statements made herein are not made on behalf of NIAID.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: Copy converts tabs to spaces ?
       [not found]     ` <B7021E1A-156E-4F9B-ADFC-B6DE58D5E14D@NSG-GmbH.de>
  2009-02-07 13:25       ` Buchbinder, Barry (NIH/NIAID) [E]
@ 2009-02-07 17:24       ` Paul McFerrin
  2009-02-08 16:30         ` tmcd
  1 sibling, 1 reply; 8+ messages in thread
From: Paul McFerrin @ 2009-02-07 17:24 UTC (permalink / raw)
  To: cygwin; +Cc: 'Ralf Gans'

>>> On 02.02.2009, at 11:05, xerces8 wrote:
>>>> I noticed that when copying text from a the Cygwin Bash window and
>>>> then pasting it somewhere (like WordPad), tabulator characters are
>>>> converted to spaces. 
>>>> 
>>>> The same happens with RXVT too.
>>>> 
>>>> Details:
>>>> - print the content of some text file that has tabs (like a C
>>>> program source) : cat foo.c 
>>>> - select and copy the text with the mouse
>>>> - paste (ctrl-V) into WordPad
>>>> 
>>>> The text in Wordpad has no more tabs.
>>>> 
>>>> Is there a way around this ?
>>> 
>>> copy an paste from window to window takes what's printed, not what
>>> you have written. 
>>> 
>>> So, if the terminal prints spaces to represent the tabs, as a
>>> terminal usually does, you CAN only copy spaces.

Let me add my 2 cents worth.  If you have the "newform" command, the 
following magic will work:

	$ newform -i-8 -o0 input_file >output_file

I have newform but i'm not sure where i got it since I was a long-time 
AT&T Unix user.  I also didn't find a man page.  It's a very handy tool.

Translations:
	-i-8 = input tabs assumed to be at every 8 columns
	-o0 = output has tabs at 0 (no tabs)

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: Copy converts tabs to spaces ?
  2009-02-07 17:24       ` Paul McFerrin
@ 2009-02-08 16:30         ` tmcd
  0 siblings, 0 replies; 8+ messages in thread
From: tmcd @ 2009-02-08 16:30 UTC (permalink / raw)
  Cc: cygwin

On Sat, 7 Feb 2009, Paul McFerrin <pmcferrin@columbus.rr.com> wrote:
> [someone back there wrote]
> > On 02.02.2009, at 11:05, xerces8 wrote:
> > > I noticed that when copying text from a the Cygwin Bash
> > > window and then pasting it somewhere (like WordPad),
> > > tabulator characters are converted to spaces.
> > > The same happens with RXVT too.
> > >
> > > Details:
> > > - print the content of some text file that has tabs (like a
> > > C program source) : cat foo.c - select and copy the text
> > > with the mouse
> > > - paste (ctrl-V) into WordPad
> > >
> > > The text in Wordpad has no more tabs.
> > >
> > > Is there a way around this ?
> >
> > copy an paste from window to window takes what's printed, not what
> > you have written.
> >
> > So, if the terminal prints spaces to represent the tabs, as a
> > terminal usually does, you CAN only copy spaces.
>
> Let me add my 2 cents worth.  If you have the "newform" command, the
> following magic will work:
>
> 	$ newform -i-8 -o0 input_file >output_file
>
> I have newform but i'm not sure where i got it since I was a
> long-time AT&T Unix user.  I also didn't find a man page.  It's a
> very handy tool.
>
> Translations:
> 	-i-8 = input tabs assumed to be at every 8 columns
> 	-o0 = output has tabs at 0 (no tabs)

"expand" and "unexpand" do tab<->space conversions and have been in
UNIXy systems since the early 1980s.  Is there something that newform
does that they don't?

-- 
Tim McDaniel; Reply-To: tmcd@panix.com

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-02-08 16:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-02 10:06 Copy converts tabs to spaces ? xerces8
2009-02-02 10:27 ` Sisyphus
2009-02-02 10:42   ` Sisyphus
2009-02-02 13:57 ` Ralf Gans
2009-02-02 20:16   ` Buchbinder, Barry (NIH/NIAID) [E]
     [not found]     ` <B7021E1A-156E-4F9B-ADFC-B6DE58D5E14D@NSG-GmbH.de>
2009-02-07 13:25       ` Buchbinder, Barry (NIH/NIAID) [E]
2009-02-07 17:24       ` Paul McFerrin
2009-02-08 16:30         ` tmcd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).