Mojca Miklavec wrote:
On 12/26/06, Yongwei Wu wrote:
Maybe try

:help 'fileformats'
:setg fileformats?

I've read the help page, but I don't manage to deduce a solution out
of it. Without -u NONE it works OK, but if I say
   vim -u NONE -c "set fileformats=unix,dos" filename
it diesn't really help. fileformats is properly set, but fileformat is
still set to unix.

Mojca


On 12/26/06, Mojca Miklavec wrote:
> Hello,
>
> two of us are experimeting with using vim as an external
> syntax-highlighter for TeX documents.
>
> This file resulted from adapting 2html.vim:
>     http://pub.mojca.org/tex/vim/syntax/2context.vim
>
> Here's how vim is called now:
>
> vim -u NONE
>            -e
>            -V10log
>            -c "set nocp"
>            -c "syntax on"
>            -c "set syntax={filetype}"
>            -c "source 2context.vim"
>            -c "wqa" {filename}
>
> However, after using "-u NONE" (in order to assure compatibility among
> different users), I now have problems converting [dos] files on linux.
> If I take a [dos] file, I get
>
> first line^M
> second line^M
>
> etc. I temporary solved the problem by adding
>     let s:line = substitute(s:line, '\r', '', 'g')
> but this will fail for mac fileformat.
>
> So: how should the function be implemented, so that reading will work
> for any combination of endline characters (<CR><NL>, <NL> and <CR>) on
> any system? It's only important to read it properly, writing mode is
> not that important since TeX can hopefully handle any of the three
> possibilities.
>
> Thanks a lot for any hints,
>     Mojca


From options.txt:
If all lines end in <CR><NL> and 'fileformats' includes "dos", 'fileformat' will be set to "dos"

So here are the cases where you will see lines ending in ^M :
- 'fileformats' doesn't include "dos" at the time the file is opened.
- File has mixed fileformat, with some lines ending in <CR><LF> and others ending in <LF> only.
- All lines end in <CR><LF> but some have a second <CR> just before that.

Contrary to my previous post, it will help (in some marginal cases) if you use ":set ffs:dos,unix,mac" with "dos" before "unix" because in that case (IIUC) mixed-format lines may still in some cases (not all, though) be read in Dos format, where NL-only is still recognised as an end-of-line.

If it works for you without -u NONE but not with it, it may mean that the settings are set too late (i.e., after loading the file and setting its 'fileformat' erroneously to "unix" or to the empty string.

Try replacing -c by --cmd in order to apply the commands _before_ reading the editfile.


Best regards,
Tony.

Reply via email to