Trailing ^M ...

2009-04-22 Thread Kiffin Gish

What's the quickest way to remove all the trailing ^M characters in my
file?

-  
Kiffin Gish 
Gouda, The Netherlands




--~--~-~--~~~---~--~~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Trailing ^M ...

2009-04-22 Thread Tim Chase

Kiffin Gish wrote:
> What's the quickest way to remove all the trailing ^M characters in my
> file?

Though I think this is one of the FAQs, it's faster to just reply:

   :%s/\r

than to dig up a link to the FAQ :)

-tim



--~--~-~--~~~---~--~~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



RE: Trailing ^M ...

2009-04-22 Thread John Beckett

Kiffin Gish wrote:
> What's the quickest way to remove all the trailing ^M
> characters in my file?

Tim has beaten me again, but as a matter of interest, the tip
follows (that stuff on the end is "^M"):
http://vim.wikia.com/wiki/%5EM

John


--~--~-~--~~~---~--~~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Trailing ^M ...

2009-04-28 Thread Tony Mechelynck

On 22/04/09 11:31, Kiffin Gish wrote:
>
> What's the quickest way to remove all the trailing ^M characters in my
> file?
>
> -
> Kiffin Gish
> Gouda, The Netherlands

IMHO, in Vim 7.2.040 and later, by opening it with

:e ++ff=dos somestuff.txt

This will force Vim to read it as if it were a DOS file, which in turn 
means that CR (carriage return, or ^M) characters will be ignored 
whenever they are immediately followed by a LF (linefeed), and that LF 
will be accepted as an end-of-line marker regardless of whether it is 
preceded by a CR.

Then if you want to write it with LF-only ("Unix-style") ends of lines, 
so that no Unix program "sees" the carriage returns, use

:setlocal ff=unix

once the file is open, and before saving it; otherwise Vim will write 
the file with CR+LF ("DOS-style") ends of lines throughout, and the next 
time it reads the file, it will regard it as a "dos" file and you won't 
see the ^M characters.

(Before 7.2.040, files with mixed CR+LF and LF-only ends-of-lines would 
be opened as fileformat "unix" even if you used the ++ff=dos modifier, 
unless 'fileformats' (plural) was set to empty or just "dos".)

Trailing ^M characters mean that the file has mixed ends-of-lines 
(assuming that 'fileformats' [plural] contains both "unix" and "dos"). 
Often, such a file actually has CR+LF throughout, except on the last 
line which has nothing at all.


Best regards,
Tony.
-- 
If only God would give me some clear sign!  Like making a large deposit
in my name at a Swiss bank.
-- Woody Allen, "Without Feathers"

--~--~-~--~~~---~--~~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Trailing ^M ...

2009-04-28 Thread Tony Mechelynck

On 22/04/09 12:10, Tim Chase wrote:
>
> Kiffin Gish wrote:
>> What's the quickest way to remove all the trailing ^M characters in my
>> file?
>
> Though I think this is one of the FAQs, it's faster to just reply:
>
> :%s/\r
>
> than to dig up a link to the FAQ :)
>
> -tim

This would remove the first carriage return on any line, not necessarily 
trailing ones. To remove only trailing ones by using a ":" command, use

:%s/\r$//

(I write the ending slashes explicitly for clarity, and to allow a 
comment on the same line.)


Best regards,
Tony.
-- 
hundred-and-one symptoms of being an internet addict:
18. Your wife drapes a blond wig over your monitor to remind you of what she
 looks like.

--~--~-~--~~~---~--~~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Trailing ^M ...

2009-04-29 Thread pansz

Tony Mechelynck 写道:
> 
> IMHO, in Vim 7.2.040 and later, by opening it with
> 
>   :e ++ff=dos somestuff.txt

Things can be worse than that: I've seen files mixed with \r\r\n and 
\r\n and \n at the end of line. in which case ++ff=dos does not solve 
the problem. since there's extra ^M there.

so I'd always recommend a single command :%s/^M//g




--~--~-~--~~~---~--~~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Trailing ^M ...

2009-04-29 Thread Matt Wozniski

On Thu, Apr 30, 2009 at 2:30 AM, pansz wrote:
>
> Tony Mechelynck 写道:
>>
>> IMHO, in Vim 7.2.040 and later, by opening it with
>>
>>       :e ++ff=dos somestuff.txt
>
> Things can be worse than that: I've seen files mixed with \r\r\n and
> \r\n and \n at the end of line. in which case ++ff=dos does not solve
> the problem. since there's extra ^M there.
>
> so I'd always recommend a single command :%s/^M//g

But that would ruin a file that intentionally had ^M in it - like some
ex scripts, for instance.

~Matt

--~--~-~--~~~---~--~~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: Trailing ^M ...

2009-04-30 Thread Tony Mechelynck

On 30/04/09 08:45, Matt Wozniski wrote:
>
> On Thu, Apr 30, 2009 at 2:30 AM, pansz wrote:
>>
>> Tony Mechelynck 写道:
>>>
>>> IMHO, in Vim 7.2.040 and later, by opening it with
>>>
>>>:e ++ff=dos somestuff.txt
>>
>> Things can be worse than that: I've seen files mixed with \r\r\n and
>> \r\n and \n at the end of line. in which case ++ff=dos does not solve
>> the problem. since there's extra ^M there.
>>
>> so I'd always recommend a single command :%s/^M//g
>
> But that would ruin a file that intentionally had ^M in it - like some
> ex scripts, for instance.
>
> ~Matt

The above will remove any carriage-returns anywhere. My previous 
proposal will suppress at most one carriage-return per line, and only at 
the end. Here's an additional variant, to suppress any number of 
carriage-returns but only at the end of a line:

:%s/\r*$//

Vim regexps are pretty powerful, but of course you've got to know what 
you want to do with them.

Best regards,
Tony.
-- 
People who develop the habit of thinking of themselves as world
citizens are fulfilling the first requirement of sanity in our time.
-- Norman Cousins

--~--~-~--~~~---~--~~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Trailing ^M on Windows

2019-11-16 Thread Matteo Landi

Hello everyone,

I have been battling with trailing ^M on Windows, and I was wondering if 
any of you could help me figure it out.


Let's create a file with `\r\n`s (that's how the clipboard appears to be 
populated when I copy things from Chrome):


   > echo -en "OS cliboards are hart...\r\naren't they?\r\n" > clipboard.txt

   > cat clipboard.txt
   OS cliboards are hart...
   aren't they?

   > cat clipboard.txt -A
   OS cliboards are hart...^M$
   aren't they?^M$

Let's open up vim now (`vim -u NONE`) and do some experiments:

1) read 'clipboard.txt', under the cursor

   :read clipboard.txt

 The content is loaded, not trailing ^M, at the bottom I see: 
 "clpboard.txt" [dos format] 2 lines, 40 characters


2) load 'clipboard.txt' using `read!`

   :read! cat clipboard.txt

 The content is loaded, no trailing ^M

3) load the content into a variable, then paste it under the cursor

   :let @@ = system('cat clipboard.txt') | exe 'normal p'

 The content is loaded, trailing ^M are added

Let's now push the file into the OS clipboard:

   > cat clipboard.txt | clip.exe

Open up vim again, and:

4) paste from the `*` register (works with `Shift+Ins` too):

   :exe 'normal "*p'

 OS clipboard is read, no trailing ^M

5) load the content of the clipboard using `read!`

   :read! powershell.exe Get-Clipboard

 The content is loaded, no trailing ^M

6) Read the content of the clipboard into a variable, then paste it under the 
cursor

   :let @@ = system('powershell.exe Get-Clipboard') | exe 'normal p'

 OS clipboard is read, trailing ^M are added

These last 2 experiments, really, left me speechless: in both cases we 
are reading the output of a command, but somehow `:read` seems to strip 
^M, while `system()` not. Can someone help me figure this out?


Thanks

--
Matteo Landi
https://matteolandi.net

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups "vim_use" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/20191116112441.GA12005%40hairstyle.local.


Re: Trailing ^M on Windows

2019-11-16 Thread Tony Mechelynck
On Windows, when you read a file in Vim and every (or almost every)
line ends with ^M, it usually means that the last line lacks an
end-of-line, which made Vim read the whole file as if it were a Unix
file. This is how I would fix such a file:

:new ++ff=dos filename.ext
:wq

(this has the side-effect of opening then closing a new window for
that file) — see ":help ++opt".
Reading the file with 'fileformat' explicitly set to dos forces both
CR+LF or LF alone (or nothing at end of file) to be recognised as
ends-of-lines. Writing the file (which still has 'fileformat' set to
dos) writes a proper CR+LF Dos/Windows end-of-line at the end of every
line including the last one, so the next time you read it it will be
recognised as a Windows file and you won't see those pesky ^M (i.e.
carriage-return) characters (they are still there but they are part of
the normal Dos/Window end-of-line).

Or if you want to transmit the file to be read on a Unix system, you
can replace :wq by :wq ++ff=unix — in that case all lines will get a
proper LF-only Unix end-of-line, which both Vim (on any platform) and
any Unix program will be able to recognise properly. In this case the
^M characters are not even there so no one will see them.

Best regards,
Tony.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/CAJkCKXtDBLPtAtP0MjeBOwBzJXKKf%2BYVj5VT9F_%2BqjhMQ5xiYg%40mail.gmail.com.


Re: Trailing ^M on Windows

2019-11-16 Thread Matteo Landi

On 11/16, Tony Mechelynck wrote:

On Windows, when you read a file in Vim and every (or almost every)
line ends with ^M, it usually means that the last line lacks an
end-of-line, which made Vim read the whole file as if it were a Unix
file. This is how I would fix such a file:

   :new ++ff=dos filename.ext
   :wq

(this has the side-effect of opening then closing a new window for
that file) — see ":help ++opt".
Reading the file with 'fileformat' explicitly set to dos forces both
CR+LF or LF alone (or nothing at end of file) to be recognised as
ends-of-lines. Writing the file (which still has 'fileformat' set to
dos) writes a proper CR+LF Dos/Windows end-of-line at the end of every
line including the last one, so the next time you read it it will be
recognised as a Windows file and you won't see those pesky ^M (i.e.
carriage-return) characters (they are still there but they are part of
the normal Dos/Window end-of-line).

Or if you want to transmit the file to be read on a Unix system, you
can replace :wq by :wq ++ff=unix — in that case all lines will get a
proper LF-only Unix end-of-line, which both Vim (on any platform) and
any Unix program will be able to recognise properly. In this case the
^M characters are not even there so no one will see them.



Thanks Tony for your reply, but I am afraid I did not properly explain 
myself earlier, apologies.


The actual problem I dealing with is trailing ^M when reading from the 
OS clipboard; I started with dumping trailing \r\n data on a file only 
to make it easier for people to reproduce my problem, but ultimately I 
need to figure out how to read from the clipboard without having ^M 
added at the end of each line.


So, going back to my experiments, can anyone suggest why, the following 
strips trailing ^M:


 :read! powershell.exe Get-Clipboard

While this one instead, doesn't?

 :let @@ = system('powershell.exe Get-Clipboard') | exe 'normal p'

Also, for those who might wonder: reading from the */+ registers 
unfortunately is not an option, as I am trying build a mini-plugin 
around "cb" (https://github.com/iamFIREcracker/cb) which is a script 
that can work via ssh too where you don't have access to the OS 
clipboard; anyway, this is the reason why I am trying to read the 
content of the OS clipboard by using a command, `powershell.exe 
Get-Clipboard`, instead of using the */+ register.


Let me know if this makes things a little more clear.

Thanks.

--
Matteo Landi
https://matteolandi.net

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups "vim_use" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/20191116180552.GA13099%40hairstyle.local.


Re: Trailing ^M on Windows

2019-11-16 Thread Tony Mechelynck
On Sat, Nov 16, 2019 at 7:06 PM Matteo Landi  wrote:
>
> On 11/16, Tony Mechelynck wrote:
> >On Windows, when you read a file in Vim and every (or almost every)
> >line ends with ^M, it usually means that the last line lacks an
> >end-of-line, which made Vim read the whole file as if it were a Unix
> >file. This is how I would fix such a file:
> >
> >:new ++ff=dos filename.ext
> >:wq
> >
> >(this has the side-effect of opening then closing a new window for
> >that file) — see ":help ++opt".
> >Reading the file with 'fileformat' explicitly set to dos forces both
> >CR+LF or LF alone (or nothing at end of file) to be recognised as
> >ends-of-lines. Writing the file (which still has 'fileformat' set to
> >dos) writes a proper CR+LF Dos/Windows end-of-line at the end of every
> >line including the last one, so the next time you read it it will be
> >recognised as a Windows file and you won't see those pesky ^M (i.e.
> >carriage-return) characters (they are still there but they are part of
> >the normal Dos/Window end-of-line).
> >
> >Or if you want to transmit the file to be read on a Unix system, you
> >can replace :wq by :wq ++ff=unix — in that case all lines will get a
> >proper LF-only Unix end-of-line, which both Vim (on any platform) and
> >any Unix program will be able to recognise properly. In this case the
> >^M characters are not even there so no one will see them.
> >
>
> Thanks Tony for your reply, but I am afraid I did not properly explain
> myself earlier, apologies.
>
> The actual problem I dealing with is trailing ^M when reading from the
> OS clipboard; I started with dumping trailing \r\n data on a file only
> to make it easier for people to reproduce my problem, but ultimately I
> need to figure out how to read from the clipboard without having ^M
> added at the end of each line.
>
> So, going back to my experiments, can anyone suggest why, the following
> strips trailing ^M:
>
>   :read! powershell.exe Get-Clipboard
>
> While this one instead, doesn't?
>
>   :let @@ = system('powershell.exe Get-Clipboard') | exe 'normal p'
>
> Also, for those who might wonder: reading from the */+ registers
> unfortunately is not an option, as I am trying build a mini-plugin
> around "cb" (https://github.com/iamFIREcracker/cb) which is a script
> that can work via ssh too where you don't have access to the OS
> clipboard; anyway, this is the reason why I am trying to read the
> content of the OS clipboard by using a command, `powershell.exe
> Get-Clipboard`, instead of using the */+ register.
>
> Let me know if this makes things a little more clear.
>
> Thanks.
>
> --
> Matteo Landi
> https://matteolandi.net

My previous answer still applies to this usecase.

As the documentation for :read says, this command accepts a ++opt
modifier, even when used with an !external command.

I expect that

:read ++ff=dos !powershell.exe Get-Clipboard

(with the ++ff= modifier before the exclamation mark) will give you
the result you want, without the ^M characters. Try it, then tell us
if it works.

Best regards,
Tony.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/CAJkCKXvV7bzJfAGK%2BhnMmwqutb-Pee3gs1yv%3DKepK7929AL%3DDg%40mail.gmail.com.


Re: Trailing ^M on Windows

2019-11-18 Thread Matteo Landi
Hi Tony,

The thing is, :read! appears to be stripping ^M already, irrespective of
the use of ++opts:

  :read !powershell.exe Get-Clipboard
  :read ++ff=unix !powershell.exe Get-Clipboard
  :read ++ff=dos !powershell.exe Get-Clipboard

To be honest, I'd expect the second one, where we specify ++ff=unix, to
leave trailing ^M, but somehow that's not happening, and for your reference
(after I vim -u NONE):

  :verbose set ff

Returns 'fileformat=unix'

  :verbose set ffs

Returns 'fileformats=unix,dos'

So am I correct if I say that there is something "weird" going on with
system()?  I also found the following at the end of system()'s help page,
but somehow the experienced behavior is not the documented one:

  To make the result more system-independent, the shell output
  is filtered to replace  with  for Macintosh, and
   with  for DOS-like systems.

I even tried to give systemlist() a go, but each entry of the array still
has that trailing ^M, so it really seems like Vim cannot properly guess the
fileformat from the command output.

I am really in the dark here.

Thanks,

On Sun, Nov 17, 2019 at 5:57 AM Tony Mechelynck <
antoine.mechely...@gmail.com> wrote:

> On Sat, Nov 16, 2019 at 7:06 PM Matteo Landi 
> wrote:
> >
> > On 11/16, Tony Mechelynck wrote:
> > >On Windows, when you read a file in Vim and every (or almost every)
> > >line ends with ^M, it usually means that the last line lacks an
> > >end-of-line, which made Vim read the whole file as if it were a Unix
> > >file. This is how I would fix such a file:
> > >
> > >:new ++ff=dos filename.ext
> > >:wq
> > >
> > >(this has the side-effect of opening then closing a new window for
> > >that file) — see ":help ++opt".
> > >Reading the file with 'fileformat' explicitly set to dos forces both
> > >CR+LF or LF alone (or nothing at end of file) to be recognised as
> > >ends-of-lines. Writing the file (which still has 'fileformat' set to
> > >dos) writes a proper CR+LF Dos/Windows end-of-line at the end of every
> > >line including the last one, so the next time you read it it will be
> > >recognised as a Windows file and you won't see those pesky ^M (i.e.
> > >carriage-return) characters (they are still there but they are part of
> > >the normal Dos/Window end-of-line).
> > >
> > >Or if you want to transmit the file to be read on a Unix system, you
> > >can replace :wq by :wq ++ff=unix — in that case all lines will get a
> > >proper LF-only Unix end-of-line, which both Vim (on any platform) and
> > >any Unix program will be able to recognise properly. In this case the
> > >^M characters are not even there so no one will see them.
> > >
> >
> > Thanks Tony for your reply, but I am afraid I did not properly explain
> > myself earlier, apologies.
> >
> > The actual problem I dealing with is trailing ^M when reading from the
> > OS clipboard; I started with dumping trailing \r\n data on a file only
> > to make it easier for people to reproduce my problem, but ultimately I
> > need to figure out how to read from the clipboard without having ^M
> > added at the end of each line.
> >
> > So, going back to my experiments, can anyone suggest why, the following
> > strips trailing ^M:
> >
> >   :read! powershell.exe Get-Clipboard
> >
> > While this one instead, doesn't?
> >
> >   :let @@ = system('powershell.exe Get-Clipboard') | exe 'normal p'
> >
> > Also, for those who might wonder: reading from the */+ registers
> > unfortunately is not an option, as I am trying build a mini-plugin
> > around "cb" (https://github.com/iamFIREcracker/cb) which is a script
> > that can work via ssh too where you don't have access to the OS
> > clipboard; anyway, this is the reason why I am trying to read the
> > content of the OS clipboard by using a command, `powershell.exe
> > Get-Clipboard`, instead of using the */+ register.
> >
> > Let me know if this makes things a little more clear.
> >
> > Thanks.
> >
> > --
> > Matteo Landi
> > https://matteolandi.net
>
> My previous answer still applies to this usecase.
>
> As the documentation for :read says, this command accepts a ++opt
> modifier, even when used with an !external command.
>
> I expect that
>
> :read ++ff=dos !powershell.exe Get-Clipboard
>
> (with the ++ff= modifier before the exclamation mark) will give you
> the result you want, without the ^M characters. Try it, then tell us
> if it works.
>

Re: Trailing ^M on Windows

2019-11-18 Thread Tony Mechelynck
On Mon, Nov 18, 2019 at 4:11 PM Matteo Landi  wrote:
>
> Hi Tony,
>
> The thing is, :read! appears to be stripping ^M already, irrespective of the 
> use of ++opts:
>
>   :read !powershell.exe Get-Clipboard
>   :read ++ff=unix !powershell.exe Get-Clipboard
>   :read ++ff=dos !powershell.exe Get-Clipboard
>
> To be honest, I'd expect the second one, where we specify ++ff=unix, to leave 
> trailing ^M, but somehow that's not happening, and for your reference (after 
> I vim -u NONE):
>
>   :verbose set ff
>
> Returns 'fileformat=unix'
>
>   :verbose set ffs
>
> Returns 'fileformats=unix,dos'
>
> So am I correct if I say that there is something "weird" going on with 
> system()?  I also found the following at the end of system()'s help page, but 
> somehow the experienced behavior is not the documented one:
>
>   To make the result more system-independent, the shell output
>   is filtered to replace  with  for Macintosh, and
>    with  for DOS-like systems.
>
> I even tried to give systemlist() a go, but each entry of the array still has 
> that trailing ^M, so it really seems like Vim cannot properly guess the 
> fileformat from the command output.
>
> I am really in the dark here.

So am I.

As a last resort, the following Normal-mode mapping will remove (after
the fact) all ^M characters found at he end of a line:

:map  :%s/$//

Of course, you can replace  by something else (if for instance
your Normal-mode F5 key is already mapped).

Meaning of the {rhs}:
:   start an ex-command
%   or 1,$ : from top to bottom of the file
s   :s[ubstitute] (search and replace)
/   replace what
  (typed as such: less-than, C, etc.) : ^M (carriage return)
$   at end-of-line
/   replace by what
(nothing)   replace by nothing
/   end of replace-what text
(nothing)   no flags: replace once (at most) per line (N.B.
there can be only one end-of-line per line)
end of ex-command

Best regards,
Tony.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/CAJkCKXsaTWz2Mw-8nKe5H05_2WFG_iPNnEtMa1bCQ3aN0Ja-7g%40mail.gmail.com.


Re: Trailing ^M on Windows

2019-11-19 Thread Matteo Landi
Hi Tony,

I was actually writing a plugin for this, and since I could change its
implementation I ended up with something like (note the call to
substitute() right after system()):

function! s:paste(...) " {{{
  let l:after = get(a:, 1, 1)
  let reg_save = @@

  let @@ = system(g:cb_paste_prg)
  " XXX pastin on Windows somehow leaves trailing ^M
  " gotta figure out a better way to fix this, but
  " for now, this will do!
  let @@ = substitute(@@, "\r\n", "\n", "g")
  setlocal paste
  if l:after
exe 'normal p'
  else
exe 'normal P'
  endif
  setlocal nopaste

  let @@ = reg_save
endfunction " }}}

I will leave this here for a little while, and then I will probably
cross-post it on vim_dev.

Thanks again for the help.

On Mon, Nov 18, 2019 at 10:43 PM Tony Mechelynck <
antoine.mechely...@gmail.com> wrote:

> On Mon, Nov 18, 2019 at 4:11 PM Matteo Landi 
> wrote:
> >
> > Hi Tony,
> >
> > The thing is, :read! appears to be stripping ^M already, irrespective of
> the use of ++opts:
> >
> >   :read !powershell.exe Get-Clipboard
> >   :read ++ff=unix !powershell.exe Get-Clipboard
> >   :read ++ff=dos !powershell.exe Get-Clipboard
> >
> > To be honest, I'd expect the second one, where we specify ++ff=unix, to
> leave trailing ^M, but somehow that's not happening, and for your reference
> (after I vim -u NONE):
> >
> >   :verbose set ff
> >
> > Returns 'fileformat=unix'
> >
> >   :verbose set ffs
> >
> > Returns 'fileformats=unix,dos'
> >
> > So am I correct if I say that there is something "weird" going on with
> system()?  I also found the following at the end of system()'s help page,
> but somehow the experienced behavior is not the documented one:
> >
> >   To make the result more system-independent, the shell output
> >   is filtered to replace  with  for Macintosh, and
> >with  for DOS-like systems.
> >
> > I even tried to give systemlist() a go, but each entry of the array
> still has that trailing ^M, so it really seems like Vim cannot properly
> guess the fileformat from the command output.
> >
> > I am really in the dark here.
>
> So am I.
>
> As a last resort, the following Normal-mode mapping will remove (after
> the fact) all ^M characters found at he end of a line:
>
> :map  :%s/$//
>
> Of course, you can replace  by something else (if for instance
> your Normal-mode F5 key is already mapped).
>
> Meaning of the {rhs}:
> :   start an ex-command
> %   or 1,$ : from top to bottom of the file
> s   :s[ubstitute] (search and replace)
> /   replace what
>   (typed as such: less-than, C, etc.) : ^M (carriage
> return)
> $   at end-of-line
> /   replace by what
> (nothing)   replace by nothing
> /   end of replace-what text
> (nothing)   no flags: replace once (at most) per line (N.B.
> there can be only one end-of-line per line)
> end of ex-command
>
> Best regards,
> Tony.
>
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups
> "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to vim_use+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/vim_use/CAJkCKXsaTWz2Mw-8nKe5H05_2WFG_iPNnEtMa1bCQ3aN0Ja-7g%40mail.gmail.com
> .
>

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/CAKpQHWbLxLLvgQhRBX1b5Lg8xZZYWKAM-rJa4aw3Ofvyhkaqug%40mail.gmail.com.


Re: Trailing ^M on Windows

2019-11-28 Thread 'Andy Wokula' via vim_use

Am 16.11.2019 um 12:25 schrieb Matteo Landi:

Hello everyone,

I have been battling with trailing ^M on Windows


Are you using the Cygwin version of Vim?
:echo has('win32unix')

--
Andy

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups "vim_use" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/5DDFF358.6000502%40yahoo.de.


Re: Trailing ^M on Windows

2019-11-28 Thread Matteo Landi
Yes, it was the Cygwin version of Vim. Is it expected to behave
differently, in terms of EOL automatic recognition? (sorry for asking
something I could have checked myself, but I am on the go, and figured it'd
be best if I replied to you and kept thr thread alive).

Thanks

Il gio 28 nov 2019, 17:18 'Andy Wokula' via vim_use <
vim_use@googlegroups.com> ha scritto:

> Am 16.11.2019 um 12:25 schrieb Matteo Landi:
> > Hello everyone,
> >
> > I have been battling with trailing ^M on Windows
>
> Are you using the Cygwin version of Vim?
>  :echo has('win32unix')
>
> --
> Andy
>
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups
> "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to vim_use+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/vim_use/5DDFF358.6000502%40yahoo.de.
>

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/CAKpQHWYZd9BMxEG2ZgrDn_A-zvG0H-7aa1u0pnQ6fcfTaVPDfg%40mail.gmail.com.