This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Copy converts tabs to spaces ?


> 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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]