Thursday, March 23, 2017

Re: Edit a Mac file with 0x13 CR newlines on Windows?

On Thu, Mar 23, 2017 at 4:02 PM, Paul Watson <paul.hermeneutic@gmail.com> wrote:
> Is it possible on Windows to edit a old-style, pre-OS/X file from a Mac that uses 0x0D (CR) as the newline? If so, how?
>
> Does this have something to do with 'set ffs='?

Yes. The 'fileformats' option specifies which fileformat(s) you want
Vim to recognize. It is a comma-separated list:

unix: each line ends with a single <NL>, 0x10
dos: each line ends with a <CR><NL> pair, 0x13 0x10 in that order.
mac: each line ends with only a <CR>, 0x13.

Depending on the option's value, Vim will try to determine the
'fileformat' used for the file and set that. Note that Windows
(dos-format) files lacking an end-of-line on their last line will
usually be detected as "unix" if 'fileformats' includes it, displaying
a ^M at the end of all other lines, and that when trying to read a
file as "dos" (either because the option does not include "unix" or
because you forced dos mode, see below) lines lacking a <CR> before
the <NL> will be silently accepted.

To force a certain fileformat, add e.g. ++ff=mac between the command
(:edit, :new, :vsplit, etc.) and the filename.

See:
:help 'fileformats'
:help 'fileformat'
:help file-formats
:help ++opt

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.
For more options, visit https://groups.google.com/d/optout.

No comments: