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

Re: compatibility with Sun's original vi for command :su

Expand Messages
  • Salman Halim
    ... Or, if you want to make sure it s only after a colon (and not after every occurrence of su ), look up getcmdpos() and only act if it s at the beginning of
    Message 1 of 7 , Jun 24, 2013
    • 0 Attachment
      On Monday, June 24, 2013, Paul Maier wrote:
      Hi,

      the original vi on Sun took :su as :suspend,
      whereas vim takes :su as :substitute.

      I am very used to typing :su.

      Would it be possible for VIM 7.4 to add a new compatibility flag to cpoptions
      about the meaning of :su ?

      suggested compatible flag:  :su = :suspend,  :s = :substitute
      without the flag:           :su = :substitute

      Thanks for responding!
        Paul


      Why not just do something like:

      :cab su substitute

      Or, if you want to make sure it's only after a colon (and not after every occurrence of "su"), look up getcmdpos() and only act if it's at the beginning of the command-line.

      Hope this helps,

      Salman


      --
      سلمان حلیم

      --
      --
      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@....
      For more options, visit https://groups.google.com/groups/opt_out.
       
       
    • Matteo Cavalleri
      ... what does :su do? it s the same as pressing CTRL-z or typing :sh ? -- -- You received this message from the vim_use maillist. Do not top-post! Type
      Message 2 of 7 , Jun 25, 2013
      • 0 Attachment
        Il giorno lunedì 24 giugno 2013 23:54:43 UTC+2, Paul Maier ha scritto:

        > the original vi on Sun took :su as :suspend,
        >
        > whereas vim takes :su as :substitute.

        what does ":su" do? it's the same as pressing CTRL-z or typing ":sh"?

        --
        --
        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@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • Tony Mechelynck
        ... Matteo: see :help :suspend Paul: Either use Salman s cabbrev trick (more later) or use :st instead (for :stop which in Vim is a synonym for :suspend). A
        Message 3 of 7 , Jun 25, 2013
        • 0 Attachment
          On 25/06/13 10:01, Matteo Cavalleri wrote:
          > Il giorno lunedì 24 giugno 2013 23:54:43 UTC+2, Paul Maier ha scritto:
          >
          >> the original vi on Sun took :su as :suspend,
          >>
          >> whereas vim takes :su as :substitute.
          >
          > what does ":su" do? it's the same as pressing CTRL-z or typing ":sh"?
          >
          Matteo: see :help :suspend

          Paul: Either use Salman's cabbrev trick (more later) or use :st instead
          (for :stop which in Vim is a synonym for :suspend).

          A more involved cabbrev trick for your vimrc:

          if version < 700
          cnoreabbrev su suspend
          else
          cnoreabbrev <expr> su
          \ ((getcmdtype() == ':' && getcmdpos() <= 3)? 'suspend' : 'su')
          endif


          The above assumes 'nocompatible' (otherwise, you can still use it, but
          the long cnoreabbrev <expr> line must be typed all on one line with no
          line continuation) and determines at run-time whether the "finer"
          version of the mapping (with getcmdtype() and getcmdpos()) can be used
          or not.

          I intentionally use "version" rather than "v:version" because it is more
          backward-compatible.


          Best regards,
          Tony.
          --
          Without ice cream life and fame are meaningless.

          --
          --
          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@....
          For more options, visit https://groups.google.com/groups/opt_out.
        • Christian Brabandt
          ... Looks like a bug to me. POSIX also requires :su to be used for ... Do we need a new cpo setting here, or should it be enough to patch vim to take :su as
          Message 4 of 7 , Jun 25, 2013
          • 0 Attachment
            On Mon, June 24, 2013 23:54, Paul Maier wrote:
            > Hi,
            >
            > the original vi on Sun took :su as :suspend,
            > whereas vim takes :su as :substitute.
            >
            > I am very used to typing :su.
            >
            > Would it be possible for VIM 7.4 to add a new compatibility flag to
            > cpoptions
            > about the meaning of :su ?
            >
            > suggested compatible flag: :su = :suspend, :s = :substitute
            > without the flag: :su = :substitute
            >

            Looks like a bug to me. POSIX also requires :su to be used for
            :suspend (http://pubs.opengroup.org/onlinepubs/007908799/xcu/ex.html)

            Do we need a new cpo setting here, or should it be enough to
            patch vim to take :su as :suspend?

            regards,
            Christian

            --
            --
            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@....
            For more options, visit https://groups.google.com/groups/opt_out.
          • Bram Moolenaar
            ... The POSIX spec has a bug: it says that :s means :substitute, which means anything starting with :s means :substitute, including :su. But then ... Relevant
            Message 5 of 7 , Jun 25, 2013
            • 0 Attachment
              Christian Brabandt wrote:

              > On Mon, June 24, 2013 23:54, Paul Maier wrote:
              > > Hi,
              > >
              > > the original vi on Sun took :su as :suspend,
              > > whereas vim takes :su as :substitute.
              > >
              > > I am very used to typing :su.
              > >
              > > Would it be possible for VIM 7.4 to add a new compatibility flag to
              > > cpoptions
              > > about the meaning of :su ?
              > >
              > > suggested compatible flag: :su = :suspend, :s = :substitute
              > > without the flag: :su = :substitute
              > >
              >
              > Looks like a bug to me. POSIX also requires :su to be used for
              > :suspend (http://pubs.opengroup.org/onlinepubs/007908799/xcu/ex.html)
              >
              > Do we need a new cpo setting here, or should it be enough to
              > patch vim to take :su as :suspend?

              The POSIX spec has a bug: it says that :s means :substitute, which means
              anything starting with :s means :substitute, including :su. But then
              :suspend can be abbreviated to :su, that's a conflict.

              Relevant quotes:

              For each of the commands listed below, the command can be
              entered as the abbreviation (those characters in the Synopsis
              command word preceding the [), the full command (all characters
              shown for the command word, omitting the [ and ]), or any subset
              of the characters of the full command down to the abbreviation.
              For example, the args command (shown as ar[gs] in the Synopsis)
              can be entered as ar, arg or args.

              [...]

              Substitute

              Synopsis: [range] s[ubstitute] [/pattern/repl/[options] [count] [flags]]

              [...]

              Suspend

              Synopsis: su[spend][!]


              Making an exception for :su to mean :suspend instead of :substitute
              would be weird.

              --
              GALAHAD: No. Look, I can tackle this lot single-handed!
              GIRLS: Yes, yes, let him Tackle us single-handed!
              "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

              /// 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_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@....
              For more options, visit https://groups.google.com/groups/opt_out.
            • Paul Maier
              ... The compatibility mode tries to emulate the behaviour of original Sun s vi, even if it is a bug there. Vim does this at several places. With a new cpo
              Message 6 of 7 , Jun 26, 2013
              • 0 Attachment
                Bram wrote:
                > The POSIX spec has a bug: it says that :s means :substitute, which means
                > anything starting with :s means :substitute, including :su. But then
                > :suspend can be abbreviated to :su, that's a conflict.

                The compatibility mode tries to emulate the behaviour of original Sun's vi,
                even if it is a bug there. Vim does this at several places.

                With a new cpo flag, the user would have a choice to configure vim to personal
                habits. (I have been using original Sun vi for 10 years, typing :su, not
                considering that I am using a bug. Now I am used to it.)


                Tony wrote:
                > cnoreabbrev <expr> su
                > \ ((getcmdtype() == ':' && getcmdpos() <= 3)? 'suspend' : 'su')

                Thanks Tony, this works 100% great!


                In case you developer guys don't want a new cpo flag, maybe you want to add
                Tony's line to the help page.
                (see :help Y for an example of such a line in the help)


                Regards,
                Paul


                --
                --
                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@....
                For more options, visit https://groups.google.com/groups/opt_out.
              Your message has been successfully submitted and would be delivered to recipients shortly.