On Mon, Nov 18, 2019 at 4:11 PM Matteo Landi <matteo@matteolandi.net> 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 <CR> with <NL> for Macintosh, and
> <CR><NL> with <NL> 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 <F5> :%s/<Ctrl-M>$//<CR>
Of course, you can replace <F5> 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
<Ctrl-M> (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)
<CR> 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+unsubscribe@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.
Monday, November 18, 2019
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment