Loading ...
Sorry, an error occurred while loading the content.
 

Re: set ff=dos problems

Expand Messages
  • Noel Henson
    ... Mike, If you need it, there is a script to convert between dos/unix/mac EOLs here: www.noels-lab.com/crlf.html. I know it s not the same, but it might
    Message 1 of 17 , Dec 1, 2008
      On Sunday 30 November 2008, Mike Hoy wrote:
      > In my .vimrc file I have:
      >
      > set ff=dos
      >
      > and it doesn't format my files for dos. I have to type it out before
      > saving it. Any way to automate this? My instructor only uses notepad
      > to view code and I'm on GNU/Linux. I'd like to be able to just use vim
      > and it automatically saves it in dos format.

      Mike,

      If you need it, there is a script to convert between dos/unix/mac EOLs
      here: www.noels-lab.com/crlf.html.

      I know it's not the same, but it might help.

      Noel

      --

      ------------------------------------------------------------------
      Noel Henson
      www.noels-lab.com Chips, firmware and embedded systems
      www.vimoutliner.org Work fast. Think well.


      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • fritzophrenic
      For *NEW* files to default to dos format, all you d need to do is (in your vimrc) :set ffs=dos,unix,mac or :set ffs=dos,unix instead of the default
      Message 2 of 17 , Dec 2, 2008
        For *NEW* files to default to dos format, all you'd need to do is (in
        your vimrc) :set ffs=dos,unix,mac or :set ffs=dos,unix instead of the
        default ffs=unix,dos.

        This will still detect existing files, and you will need to convert
        them if you created them as unix files.

        I actually used something similar to fix the opposite problem, as I do
        most editing in Windows and log into a Unix terminal to use various
        utilities on them, some of which require unix line endings.
        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Yongwei Wu
        ... It does not work for me. :set ff=unix in _vimrc works for me, but only before I open a new a DOS file. It seems nothing works stably for new file (on
        Message 3 of 17 , Dec 2, 2008
          2008/12/3 fritzophrenic <fritzophrenic@...>:
          >
          > For *NEW* files to default to dos format, all you'd need to do is (in
          > your vimrc) :set ffs=dos,unix,mac or :set ffs=dos,unix instead of the
          > default ffs=unix,dos.

          It does not work for me. :set ff=unix in _vimrc works for me, but
          only before I open a new a DOS file. It seems nothing works stably
          for new file (on Windows) to achieve your purpose.

          --
          Wu Yongwei
          URL: http://wyw.dcweb.cn/

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • fritzophrenic
          ... What exactly doesn t work about it? If you set ffs (note the s at the end, to get the fileformatS option and not the fileformaT option) to unix,dos in
          Message 4 of 17 , Dec 3, 2008
            On Dec 2, 10:58 pm, "Yongwei Wu" <wuyong...@...> wrote:
            > 2008/12/3 fritzophrenic <fritzophre...@...>:
            >
            >
            >
            > > For *NEW* files to default to dos format, all you'd need to do is (in
            > > your vimrc) :set ffs=dos,unix,mac or :set ffs=dos,unix instead of the
            > > default ffs=unix,dos.
            >
            > It does not work for me.  :set ff=unix in _vimrc works for me, but
            > only before I open a new a DOS file.  It seems nothing works stably
            > for new file (on Windows) to achieve your purpose.
            >

            What exactly "doesn't work" about it?

            If you set ffs (note the 's' at the end, to get the fileformatS option
            and not the fileformaT option) to unix,dos in Windows, every NEW file
            you create WITHIN Vim should have a unix encoding. However, if you
            edit an EXISTING file from within Vim, possibly even an "empty" one
            that you just created from somewhere else, Vim will automatically
            detect the line ending style that already exists in the file. This is
            most certainly desired behavior!

            If you want to override the 'ffs' option for certain file types on a
            read, you can put "setlocal ff=unix" or whatever is desired in an
            autocmd or ftplugin file, as has already been suggested.

            For example, although I like most of my files to have unix line
            endings, and thus have "set ffs=unix,dos" in my vimrc, I like to have
            dos line endings in my DOS batch files, so in $HOME/vimfiles/ftplugin/
            dosbatch.vim, I have "setlocal ff=dos" to automatically enforce the
            dos line endings on all dos files when created or read.
            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_use" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • Yongwei Wu
            ... Exactly as it literally means. When I have :set ffs=unix,dos in _vimrc, the empty file on opening vim, or results of :enew, still has ff=dos on Windows. I
            Message 5 of 17 , Dec 3, 2008
              2008/12/3 fritzophrenic <fritzophrenic@...>:
              > On Dec 2, 10:58 pm, "Yongwei Wu" <wuyong...@...> wrote:
              >> 2008/12/3 fritzophrenic <fritzophre...@...>:
              >>
              >> > For *NEW* files to default to dos format, all you'd need to do is
              >> > (in your vimrc) :set ffs=dos,unix,mac or :set ffs=dos,unix
              >> > instead of the default ffs=unix,dos.
              >>
              >> It does not work for me. :set ff=unix in _vimrc works for me, but
              >> only before I open a new a DOS file. It seems nothing works stably
              >> for new file (on Windows) to achieve your purpose.
              >>
              >
              > What exactly "doesn't work" about it?

              Exactly as it literally means. When I have :set ffs=unix,dos in
              _vimrc, the empty file on opening vim, or results of :enew, still has
              ff=dos on Windows.

              I even tried putting set ffs=unix,dos in a test.vim, and started vim
              with gvim -u test.vim --noplugin, and the result was still the same:
              ff=dos. Putting in set ff=unix has effects.

              I really can't imagine why it works for you.

              I am using gvim 7.2.60 on Windows XP.

              Best regards,

              Yongwei

              --
              Wu Yongwei
              URL: http://wyw.dcweb.cn/

              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_use" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            • fritzophrenic
              ... That s bizarre. What about the output of :verbose set ffs? in both cases? I don t think it should matter, but: Using the -u argument has the side
              Message 6 of 17 , Dec 4, 2008
                On Dec 3, 7:47 pm, "Yongwei Wu" <wuyong...@...> wrote:
                > When I have :set ffs=unix,dos in
                > _vimrc, the empty file on opening vim, or results of :enew, still has
                > ff=dos on Windows.
                >
                > I even tried putting set ffs=unix,dos in a test.vim, and started vim
                > with gvim -u test.vim --noplugin, and the result was still the same:
                > ff=dos. Putting in set ff=unix has effects.

                That's bizarre. What about the output of ":verbose set ffs?" in both
                cases?

                I don't think it should matter, but:

                "Using the '-u' argument has the side effect that the 'compatible'
                option will be on by default." (:help -u)

                Maybe you are setting 'nocompatible' somewhere after you set the ffs
                value, resetting it to the default?

                >
                > I really can't imagine why it works for you.
                >

                And I can't imagine why it doesn't for you :-)

                > I am using gvim 7.2.60 on Windows XP.
                >

                Me, too. The 'cream' compile from sourceforge.
                --~--~---------~--~----~------------~-------~--~----~
                You received this message from the "vim_use" maillist.
                For more information, visit http://www.vim.org/maillist.php
                -~----------~----~----~----~------~----~------~--~---
              • Yongwei Wu
                ... Path to my test.vim. ... Adding :set nocompatible in test.vim makes no difference. ... And it does not matter, since I checked the value of ffs in vim. ...
                Message 7 of 17 , Dec 4, 2008
                  2008/12/4 fritzophrenic <fritzophrenic@...>:
                  > On Dec 3, 7:47 pm, "Yongwei Wu" <wuyong...@...> wrote:
                  >> When I have :set ffs=unix,dos in
                  >> _vimrc, the empty file on opening vim, or results of :enew, still has
                  >> ff=dos on Windows.
                  >>
                  >> I even tried putting set ffs=unix,dos in a test.vim, and started vim
                  >> with gvim -u test.vim --noplugin, and the result was still the same:
                  >> ff=dos. Putting in set ff=unix has effects.
                  >
                  > That's bizarre. What about the output of ":verbose set ffs?" in both
                  > cases?

                  Path to my test.vim.

                  > I don't think it should matter, but:
                  >
                  > "Using the '-u' argument has the side effect that the 'compatible'
                  > option will be on by default." (:help -u)

                  Adding :set nocompatible in test.vim makes no difference.

                  > Maybe you are setting 'nocompatible' somewhere after you set the ffs
                  > value, resetting it to the default?

                  And it does not matter, since I checked the value of ffs in vim.

                  >> I really can't imagine why it works for you.
                  >>
                  > And I can't imagine why it doesn't for you :-)

                  Strictly speaking, my results make more sense. Vim help file does not
                  say that the first value in ffs will be used as the default encoding.
                  On the contrary, I know that setting the value of fenc will affect the
                  encoding of the empty file. And it does not persist, since neither
                  fenc nor ff is really 'global': Vim help states clearly that they are
                  local to buffer.

                  >> I am using gvim 7.2.60 on Windows XP.
                  >>
                  >
                  > Me, too. The 'cream' compile from sourceforge.

                  I use my own build (executables only), available at:

                  http://wyw.dcweb.cn/download.asp?path=vim&file=gvim72.zip

                  You may have a try, but I do not think it can make a difference. I
                  would rather think your environment affected. Did you try with -u
                  test.vim, as I did?

                  Best regards,

                  Yongwei

                  --
                  Wu Yongwei
                  URL: http://wyw.dcweb.cn/

                  --~--~---------~--~----~------------~-------~--~----~
                  You received this message from the "vim_use" maillist.
                  For more information, visit http://www.vim.org/maillist.php
                  -~----------~----~----~----~------~----~------~--~---
                • Tony Mechelynck
                  ... If you want to start Vim with standard startup scripts, it is also possible: cd C: Program Files vim vim72 . gvim -u vimrc_example.vim starts with a
                  Message 8 of 17 , Dec 4, 2008
                    On 04/12/08 15:03, fritzophrenic wrote:
                    >
                    >
                    > On Dec 3, 7:47 pm, "Yongwei Wu"<wuyong...@...> wrote:
                    >> When I have :set ffs=unix,dos in
                    >> _vimrc, the empty file on opening vim, or results of :enew, still has
                    >> ff=dos on Windows.
                    >>
                    >> I even tried putting set ffs=unix,dos in a test.vim, and started vim
                    >> with gvim -u test.vim --noplugin, and the result was still the same:
                    >> ff=dos. Putting in set ff=unix has effects.
                    >
                    > That's bizarre. What about the output of ":verbose set ffs?" in both
                    > cases?
                    >
                    > I don't think it should matter, but:
                    >
                    > "Using the '-u' argument has the side effect that the 'compatible'
                    > option will be on by default." (:help -u)
                    >
                    > Maybe you are setting 'nocompatible' somewhere after you set the ffs
                    > value, resetting it to the default?
                    >
                    >> I really can't imagine why it works for you.
                    >>
                    >
                    > And I can't imagine why it doesn't for you :-)
                    >
                    >> I am using gvim 7.2.60 on Windows XP.
                    >>
                    >
                    > Me, too. The 'cream' compile from sourceforge.



                    If you want to start Vim with standard startup scripts, it is also possible:

                    cd "C:\Program Files\vim\vim72"
                    .\gvim -u vimrc_example.vim

                    starts with a standard vimrc which sets 'nocompatible'. It also loads
                    all global plugins.

                    gvim -u NORC -N

                    starts gvim with plugins but no vimrc, in 'nocompatible' mode.

                    gvim -u NONE -N

                    starts gvim in 'nocompatible' mode with no vimrc and no plugins.

                    gvim -u test.vim --noplugin

                    starts with no plugins and test.vim as the only vimrc. 'compatible' will
                    be on unless and until test.vim sets 'nocompatible'.

                    And so on.

                    I'm using an own-compiled gvim 7.2.64 with GTK2 GUI on openSUSE Linux,
                    so I don't think my results are easily comparable with yours what
                    concerns platform-dependent options like 'ff' and 'ffs'.


                    Best regards,
                    Tony.
                    --
                    It's the thought, if any, that counts!

                    --~--~---------~--~----~------------~-------~--~----~
                    You received this message from the "vim_use" maillist.
                    For more information, visit http://www.vim.org/maillist.php
                    -~----------~----~----~----~------~----~------~--~---
                  • Tony Mechelynck
                    On 04/12/08 15:24, Yongwei Wu wrote: [...] ... [...] All buffer-local option have a global counterpart. :set option=value sets both. :setlocal option=value
                    Message 9 of 17 , Dec 4, 2008
                      On 04/12/08 15:24, Yongwei Wu wrote:
                      [...]
                      > Strictly speaking, my results make more sense. Vim help file does not
                      > say that the first value in ffs will be used as the default encoding.
                      > On the contrary, I know that setting the value of fenc will affect the
                      > encoding of the empty file. And it does not persist, since neither
                      > fenc nor ff is really 'global': Vim help states clearly that they are
                      > local to buffer.
                      [...]

                      All buffer-local option have a global counterpart. ":set option=value"
                      sets both. ":setlocal option=value" sets only the current local value.
                      ":setglobal option=value" sets only the global default. OTOH, ":set
                      option?" displays the current local value if any; you need ":setglobal
                      option?" to display the global value. In the latter two cases, prefixing
                      with ":verbose " tells you where the value in question was set.

                      See ":help local-options".

                      Normally, the global setting is used when creating a file which doesn't
                      yet exist. However, in the case of 'fenc' 'ff' and 'binary', the ++enc,
                      ++ff, ++bin and ++nobin arguments to ":edit" (and some other commands)
                      can override this.

                      See ":help ++opt".


                      Best regards,
                      Tony.
                      --
                      "I'd love to go out with you, but I'm doing door-to-door collecting for
                      static cling."

                      --~--~---------~--~----~------------~-------~--~----~
                      You received this message from the "vim_use" maillist.
                      For more information, visit http://www.vim.org/maillist.php
                      -~----------~----~----~----~------~----~------~--~---
                    • fritzophrenic
                      ... Indirectly, it does. ... 1. If all lines end in , and fileformats includes dos , fileformat is set to dos . 2. If a is found and
                      Message 10 of 17 , Dec 4, 2008
                        On Dec 4, 8:24 am, "Yongwei Wu" <wuyong...@...> wrote:
                        > Strictly speaking, my results make more sense.  Vim help file does not
                        > say that the first value in ffs will be used as the default encoding.

                        Indirectly, it does.

                        :help 'ffs' gives:

                        1. If all lines end in <CR><NL>, and 'fileformats' includes "dos",
                        'fileformat' is set to "dos".
                        2. If a <NL> is found and 'fileformats' includes "unix",
                        'fileformat'
                        is set to "unix". Note that when a <NL> is found without a
                        preceding <CR>, "unix" is preferred over "dos".
                        3. If 'fileformats' includes "mac", 'fileformat' is set to "mac".
                        This means that "mac" is only chosen when "unix" is not present,
                        or when no <NL> is found in the file, and when "dos" is not
                        present, or no <CR><NL> is present in the file.
                        Also if "unix" was first chosen, but the first <CR> is before
                        the first <NL> and there appears to be more <CR>'s than <NL>'s
                        in
                        the file, then 'fileformat' is set to "mac".
                        4. If 'fileformat' is still not set, the first name from
                        'fileformats' is used.

                        For new files created in Vim, there are no line endings yet in the
                        file, so 1, 2, and 3 all fail. Hence, 4 "defaults" to deciding that
                        "the first name from 'fileformats' is used.

                        This is actually specified explicitly in :help :new and :help :enew:

                        "If 'fileformats' is not empty, the first format given will be used
                        for the new buffer."

                        > I
                        > would rather think your environment affected.  Did you try with -u
                        > test.vim, as I did?
                        >

                        No, but I tried like this:

                        gvim -N -u NONE -i NONE
                        :set ffs=unix,dos
                        :tabnew
                        :set ff?

                        fileformat=unix

                        gvim -N -u NONE -i NONE
                        :set ffs=unix,dos
                        :new
                        :set ff?

                        fileformat=unix

                        gvim -N -u NONE -i NONE
                        :set ffs=unix,dos
                        :enew
                        :set ff?

                        fileformat=dos

                        That last one is interesting. Especially since it is in direct
                        contradiction to :help :enew above.
                        --~--~---------~--~----~------------~-------~--~----~
                        You received this message from the "vim_use" maillist.
                        For more information, visit http://www.vim.org/maillist.php
                        -~----------~----~----~----~------~----~------~--~---
                      • Yongwei Wu
                        ... Our results are aligned then. I only check the ff of the empty file on opening vim and the result of :enew. Neither is affected by ffs. When I try :new and
                        Message 11 of 17 , Dec 4, 2008
                          2008/12/5 fritzophrenic <fritzophrenic@...>:
                          >
                          > On Dec 4, 8:24 am, "Yongwei Wu" <wuyong...@...> wrote:
                          >> Strictly speaking, my results make more sense. Vim help file does not
                          >> say that the first value in ffs will be used as the default encoding.
                          >
                          > Indirectly, it does.
                          >
                          > :help 'ffs' gives:
                          >
                          > 1. If all lines end in <CR><NL>, and 'fileformats' includes "dos",
                          > 'fileformat' is set to "dos".
                          > 2. If a <NL> is found and 'fileformats' includes "unix",
                          > 'fileformat'
                          > is set to "unix". Note that when a <NL> is found without a
                          > preceding <CR>, "unix" is preferred over "dos".
                          > 3. If 'fileformats' includes "mac", 'fileformat' is set to "mac".
                          > This means that "mac" is only chosen when "unix" is not present,
                          > or when no <NL> is found in the file, and when "dos" is not
                          > present, or no <CR><NL> is present in the file.
                          > Also if "unix" was first chosen, but the first <CR> is before
                          > the first <NL> and there appears to be more <CR>'s than <NL>'s
                          > in
                          > the file, then 'fileformat' is set to "mac".
                          > 4. If 'fileformat' is still not set, the first name from
                          > 'fileformats' is used.
                          >
                          > For new files created in Vim, there are no line endings yet in the
                          > file, so 1, 2, and 3 all fail. Hence, 4 "defaults" to deciding that
                          > "the first name from 'fileformats' is used.
                          >
                          > This is actually specified explicitly in :help :new and :help :enew:
                          >
                          > "If 'fileformats' is not empty, the first format given will be used
                          > for the new buffer."
                          >
                          >> I
                          >> would rather think your environment affected. Did you try with -u
                          >> test.vim, as I did?
                          >>
                          >
                          > No, but I tried like this:
                          >
                          > gvim -N -u NONE -i NONE
                          > :set ffs=unix,dos
                          > :tabnew
                          > :set ff?
                          >
                          > fileformat=unix
                          >
                          > gvim -N -u NONE -i NONE
                          > :set ffs=unix,dos
                          > :new
                          > :set ff?
                          >
                          > fileformat=unix
                          >
                          > gvim -N -u NONE -i NONE
                          > :set ffs=unix,dos
                          > :enew
                          > :set ff?
                          >
                          > fileformat=dos
                          >
                          > That last one is interesting. Especially since it is in direct
                          > contradiction to :help :enew above.

                          Our results are aligned then. I only check the ff of the empty file on
                          opening vim and the result of :enew. Neither is affected by ffs. When
                          I try :new and :tabnew now, you results can be reproduced.

                          However, since :enew and the default empty file does not work as you
                          expected, your method is not reliable. Probably you want to file a bug
                          report to Bram.

                          Best regards,

                          Yongwei

                          --
                          Wu Yongwei
                          URL: http://wyw.dcweb.cn/

                          --~--~---------~--~----~------------~-------~--~----~
                          You received this message from the "vim_use" maillist.
                          For more information, visit http://www.vim.org/maillist.php
                          -~----------~----~----~----~------~----~------~--~---
                        • Tony Mechelynck
                          ... In the meantime (until Bram changes, if ever, the behaviour of :enew to make it match the help), you may define a new command, let s say command -bang
                          Message 12 of 17 , Dec 5, 2008
                            On 05/12/08 03:54, Yongwei Wu wrote:
                            > 2008/12/5 fritzophrenic<fritzophrenic@...>:
                            >> On Dec 4, 8:24 am, "Yongwei Wu"<wuyong...@...> wrote:
                            >>> Strictly speaking, my results make more sense. Vim help file does not
                            >>> say that the first value in ffs will be used as the default encoding.
                            >> Indirectly, it does.
                            >>
                            >> :help 'ffs' gives:
                            >>
                            >> 1. If all lines end in<CR><NL>, and 'fileformats' includes "dos",
                            >> 'fileformat' is set to "dos".
                            >> 2. If a<NL> is found and 'fileformats' includes "unix",
                            >> 'fileformat'
                            >> is set to "unix". Note that when a<NL> is found without a
                            >> preceding<CR>, "unix" is preferred over "dos".
                            >> 3. If 'fileformats' includes "mac", 'fileformat' is set to "mac".
                            >> This means that "mac" is only chosen when "unix" is not present,
                            >> or when no<NL> is found in the file, and when "dos" is not
                            >> present, or no<CR><NL> is present in the file.
                            >> Also if "unix" was first chosen, but the first<CR> is before
                            >> the first<NL> and there appears to be more<CR>'s than<NL>'s
                            >> in
                            >> the file, then 'fileformat' is set to "mac".
                            >> 4. If 'fileformat' is still not set, the first name from
                            >> 'fileformats' is used.
                            >>
                            >> For new files created in Vim, there are no line endings yet in the
                            >> file, so 1, 2, and 3 all fail. Hence, 4 "defaults" to deciding that
                            >> "the first name from 'fileformats' is used.
                            >>
                            >> This is actually specified explicitly in :help :new and :help :enew:
                            >>
                            >> "If 'fileformats' is not empty, the first format given will be used
                            >> for the new buffer."
                            >>
                            >>> I
                            >>> would rather think your environment affected. Did you try with -u
                            >>> test.vim, as I did?
                            >>>
                            >> No, but I tried like this:
                            >>
                            >> gvim -N -u NONE -i NONE
                            >> :set ffs=unix,dos
                            >> :tabnew
                            >> :set ff?
                            >>
                            >> fileformat=unix
                            >>
                            >> gvim -N -u NONE -i NONE
                            >> :set ffs=unix,dos
                            >> :new
                            >> :set ff?
                            >>
                            >> fileformat=unix
                            >>
                            >> gvim -N -u NONE -i NONE
                            >> :set ffs=unix,dos
                            >> :enew
                            >> :set ff?
                            >>
                            >> fileformat=dos
                            >>
                            >> That last one is interesting. Especially since it is in direct
                            >> contradiction to :help :enew above.
                            >
                            > Our results are aligned then. I only check the ff of the empty file on
                            > opening vim and the result of :enew. Neither is affected by ffs. When
                            > I try :new and :tabnew now, you results can be reproduced.
                            >
                            > However, since :enew and the default empty file does not work as you
                            > expected, your method is not reliable. Probably you want to file a bug
                            > report to Bram.
                            >
                            > Best regards,
                            >
                            > Yongwei
                            >

                            In the meantime (until Bram changes, if ever, the behaviour of ":enew"
                            to make it match the help), you may define a new command, let's say

                            command -bang -bar -nargs=0 Enew enew<bang> | set ff=dos


                            Best regards,
                            Tony.
                            --
                            Different all twisty a of in maze are you, passages little.

                            --~--~---------~--~----~------------~-------~--~----~
                            You received this message from the "vim_use" maillist.
                            For more information, visit http://www.vim.org/maillist.php
                            -~----------~----~----~----~------~----~------~--~---
                          Your message has been successfully submitted and would be delivered to recipients shortly.