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

BUG: :new ++opt does not work

Expand Messages
  • Ingo Karkat
    Hello Vim developers, The help states: ,----[ :help :new ]---- ... `---- ,----[ :help ++opt ]---- ... `---- Therefore, I deduce that ... will (on Windows,
    Message 1 of 3 , Jul 16, 2013
    • 0 Attachment
      Hello Vim developers,

      The help states:

      ,----[ :help :new ]----
      | If 'fileformats' is not empty, the first format given will be
      | used for the new buffer. If 'fileformats' is empty, the
      | 'fileformat' of the current buffer is used. This can be
      | overridden with the |++opt| argument.
      `----

      ,----[ :help ++opt ]----
      | The [++opt] argument can be used to force the value of 'fileformat',
      | 'fileencoding' or 'binary' to a value for one command, and to specify
      | the behavior for bad characters. [...]
      | ff or fileformat overrides 'fileformat'
      `----

      Therefore, I deduce that
      :new ++ff=unix

      will (on Windows, which defaults to ff=dos) open a new, unmodified
      buffer with its fileformat set to "unix". This doesn't work, though:

      #v+
      vim -N -u NONE --cmd "set fileformats=dos,unix fileformat=dos"
      " Note: Explicit settings given only to make this reproducible on all
      platforms.
      :setl ff?
      fileformat=dos
      :new ++ff=unix
      :windo setl ff?
      fileformat=dos " This should read "unix"
      fileformat=dos
      :new +setl\ ff=unix
      :setl ff? modified?
      fileformat=unix " This works.
      modified " But marks the buffer "modified", which is not what one wants
      with :new.
      #v-

      I can reproduce this with the latest Vim 7.4a.24 (huge build on
      Linux/x64) down to Vim 7.0.000 on Windows/x86. Same problem when "dos"
      and "unix" are swapped.

      This also affects :new ++bin (binary NOT set) and :new ++enc=latin1
      (fileencoding NOT set).

      -- regards, ingo

      --
      --
      You received this message from the "vim_dev" 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_dev" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Tony Mechelynck
      ... I confirm this on 7.4a.24 (Huge) for linux-x86_64: :new ++ff=dos does *not* set fileformat to dos in the new (empty) buffer. ... However, the same
      Message 2 of 3 , Jul 16, 2013
      • 0 Attachment
        On 07/16/13 15:21, Ingo Karkat wrote:
        > Hello Vim developers,
        >
        > The help states:
        >
        > ,----[ :help :new ]----
        > | If 'fileformats' is not empty, the first format given will be
        > | used for the new buffer. If 'fileformats' is empty, the
        > | 'fileformat' of the current buffer is used. This can be
        > | overridden with the |++opt| argument.
        > `----
        >
        > ,----[ :help ++opt ]----
        > | The [++opt] argument can be used to force the value of 'fileformat',
        > | 'fileencoding' or 'binary' to a value for one command, and to specify
        > | the behavior for bad characters. [...]
        > | ff or fileformat overrides 'fileformat'
        > `----
        >
        > Therefore, I deduce that
        > :new ++ff=unix
        >
        > will (on Windows, which defaults to ff=dos) open a new, unmodified
        > buffer with its fileformat set to "unix". This doesn't work, though:
        >
        > #v+
        > vim -N -u NONE --cmd "set fileformats=dos,unix fileformat=dos"
        > " Note: Explicit settings given only to make this reproducible on all
        > platforms.
        > :setl ff?
        > fileformat=dos
        > :new ++ff=unix
        > :windo setl ff?
        > fileformat=dos " This should read "unix"
        > fileformat=dos
        > :new +setl\ ff=unix
        > :setl ff? modified?
        > fileformat=unix " This works.
        > modified " But marks the buffer "modified", which is not what one wants
        > with :new.
        > #v-
        >
        > I can reproduce this with the latest Vim 7.4a.24 (huge build on
        > Linux/x64) down to Vim 7.0.000 on Windows/x86. Same problem when "dos"
        > and "unix" are swapped.

        I confirm this on 7.4a.24 (Huge) for linux-x86_64: ":new ++ff=dos" does
        *not* set 'fileformat' to "dos" in the new (empty) buffer.

        >
        > This also affects :new ++bin (binary NOT set) and :new ++enc=latin1
        > (fileencoding NOT set).
        >
        > -- regards, ingo
        >

        However, the same does not happen when :new has a filename argument: for
        instance,

        :new ++bin foobar.baz

        (I tested it with the name of an existing file not yet opened in Vim)
        *does* set 'binary' in the newly opened buffer. Similarly, I tested it
        with ++enc=latin1 on a UTF-8 file mixing French and Russian text, and
        the French accented characters, as well as all the Russian text, looked
        garbled, showing that my (intentionally wrong) ++enc= attribute had been
        obeyed.


        Best regards,
        Tony.
        --
        Halley's Comet: It came, we saw, we drank.

        --
        --
        You received this message from the "vim_dev" 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_dev" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • Bram Moolenaar
        ... fileformat is now dos instead of unix. That indeed seems wrong. -- If the Universe is constantly expanding, why can t I ever find a parking space?
        Message 3 of 3 , Jul 17, 2013
        • 0 Attachment
          Ingo Karkat wrote:

          > The help states:
          >
          > ,----[ :help :new ]----
          > | If 'fileformats' is not empty, the first format given will be
          > | used for the new buffer. If 'fileformats' is empty, the
          > | 'fileformat' of the current buffer is used. This can be
          > | overridden with the |++opt| argument.
          > `----
          >
          > ,----[ :help ++opt ]----
          > | The [++opt] argument can be used to force the value of 'fileformat',
          > | 'fileencoding' or 'binary' to a value for one command, and to specify
          > | the behavior for bad characters. [...]
          > | ff or fileformat overrides 'fileformat'
          > `----
          >
          > Therefore, I deduce that
          > :new ++ff=unix
          >
          > will (on Windows, which defaults to ff=dos) open a new, unmodified
          > buffer with its fileformat set to "unix". This doesn't work, though:
          >
          > #v+
          > vim -N -u NONE --cmd "set fileformats=dos,unix fileformat=dos"
          > " Note: Explicit settings given only to make this reproducible on all
          > platforms.
          > :setl ff?
          > fileformat=dos
          > :new ++ff=unix
          > :windo setl ff?
          > fileformat=dos " This should read "unix"
          > fileformat=dos
          > :new +setl\ ff=unix
          > :setl ff? modified?
          > fileformat=unix " This works.
          > modified " But marks the buffer "modified", which is not what one wants
          > with :new.
          > #v-
          >
          > I can reproduce this with the latest Vim 7.4a.24 (huge build on
          > Linux/x64) down to Vim 7.0.000 on Windows/x86. Same problem when "dos"
          > and "unix" are swapped.
          >
          > This also affects :new ++bin (binary NOT set) and :new ++enc=latin1
          > (fileencoding NOT set).

          Short version:

          :set fileformats=dos,unix
          :new ++ff=unix

          'fileformat' is now "dos" instead of "unix. That indeed seems wrong.

          --
          If the Universe is constantly expanding, why can't I ever find a parking space?

          /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
          /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
          \\\ an exciting new programming language -- http://www.Zimbu.org ///
          \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

          --
          --
          You received this message from the "vim_dev" 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_dev" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        Your message has been successfully submitted and would be delivered to recipients shortly.