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

:normal with Ex commands

Expand Messages
  • David Rennalls
    Hi, The description of :normal says Execute Normal mode commands {commands}. This makes it possible to execute Normal mode commands typed on the
    Message 1 of 10 , Dec 2, 2004
    • 0 Attachment
      Hi,
      The description of :normal says
      "Execute Normal mode commands {commands}. This makes it possible to
      execute Normal mode commands typed on the command-line. {commands} is
      executed like it is typed. etc.."

      However if a try normal m`:%s/find/replace/e'`, only the mark part of
      the command gets done and not the :%s . It seems like any Ex commands
      (:) I specify with normal don't seem to work. I must be missing
      something, can anyone help ?

      - David
    • Jürgen Krämer
      Hi, ... another option is to write exe normal m`:%s/find/replace/e ` (note the backslash in front of ). Regards, Jürgen -- Jürgen Krämer
      Message 2 of 10 , Dec 2, 2004
      • 0 Attachment
        Hi,

        Tim Chase wrote:
        >
        > > However if a try normal m`:%s/find/replace/e'`, only the mark
        > > part of the command gets done and not the :%s . It seems like
        > > any Ex commands (:) I specify with normal don't seem to work.
        > > I must be missing something, can anyone help ?
        >
        > Well, the first thing I notice is that you don't have a <cr> in
        > there to indicate the end of the Ex command (just as you'd
        > normally press enter at the end of an Ex command). You may have
        > to insert it by using the ^V followed by ^M which seems to work
        > for me with a quickie example I hacked together.

        another option is to write

        exe "normal m`:%s/find/replace/e\<cr>'`"

        (note the backslash in front of <cr>).

        Regards,
        Jürgen

        --
        Jürgen Krämer Softwareentwicklung
        Habel GmbH mailto:jkr@...
        Hinteres Öschle 2 Tel: (0 74 61) 93 53 - 15
        78604 Rietheim-Weilheim Fax: (0 74 61) 93 53 - 99
      • Tim Chase
        ... Well, the first thing I notice is that you don t have a in there to indicate the end of the Ex command (just as you d normally press enter at the end
        Message 3 of 10 , Dec 2, 2004
        • 0 Attachment
          > However if a try normal m`:%s/find/replace/e'`, only the mark
          > part of the command gets done and not the :%s . It seems like
          > any Ex commands (:) I specify with normal don't seem to work.
          > I must be missing something, can anyone help ?


          Well, the first thing I notice is that you don't have a <cr> in
          there to indicate the end of the Ex command (just as you'd
          normally press enter at the end of an Ex command). You may have
          to insert it by using the ^V followed by ^M which seems to work
          for me with a quickie example I hacked together.

          -tim
        • Bram Moolenaar
          ... You need to put a CTRL-M after the command to execute it, just like what you do when you type it. For unfinished commands an is used, which cancels
          Message 4 of 10 , Dec 2, 2004
          • 0 Attachment
            David Rennalls wrote:

            > The description of :normal says
            > "Execute Normal mode commands {commands}. This makes it possible to
            > execute Normal mode commands typed on the command-line. {commands} is
            > executed like it is typed. etc.."
            >
            > However if a try normal m`:%s/find/replace/e'`, only the mark part of
            > the command gets done and not the :%s . It seems like any Ex commands
            > (:) I specify with normal don't seem to work. I must be missing
            > something, can anyone help ?

            You need to put a CTRL-M after the command to execute it, just like what
            you do when you type it. For unfinished commands an <Esc> is used,
            which cancels the Ex command.

            --
            "The future's already arrived - it's just not evenly distributed yet."
            -- William Gibson

            /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
            /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
            \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
            \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
          • David Rennalls
            ... Ahh ok that works..Thanks. I guess I should have read more carfully.. If {commands} does not finish a command, the last one will be aborted as if
            Message 5 of 10 , Dec 2, 2004
            • 0 Attachment
              On Thu, 02 Dec 2004 17:24:53 +0100, Bram Moolenaar <bram@...> wrote:
              >
              >
              >
              > David Rennalls wrote:
              >
              > > The description of :normal says
              > > "Execute Normal mode commands {commands}. This makes it possible to
              > > execute Normal mode commands typed on the command-line. {commands} is
              > > executed like it is typed. etc.."
              > >
              > > However if a try normal m`:%s/find/replace/e'`, only the mark part of
              > > the command gets done and not the :%s . It seems like any Ex commands
              > > (:) I specify with normal don't seem to work. I must be missing
              > > something, can anyone help ?
              >
              > You need to put a CTRL-M after the command to execute it, just like what
              > you do when you type it. For unfinished commands an <Esc> is used,
              > which cancels the Ex command.
              >
              > --
              > "The future's already arrived - it's just not evenly distributed yet."
              > -- William Gibson
              >
              > /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
              > /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
              > \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
              > \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
              >
              Ahh ok that works..Thanks.
              I guess I should have read more carfully.. "If {commands} does not
              finish a command, the last one will be aborted as if <Esc> or <C-C>
              was typed"

              - David
            • Antony Scriven
              ... I initially found that remark in the docs a little misleading as in the default vi-compatible configuration an on the command line executes ex
              Message 6 of 10 , Dec 2, 2004
              • 0 Attachment
                David Rennalls wrote:

                > [...] Bram Moolenaar <bram@... wrote:
                > >
                > > David Rennalls wrote:
                > >
                > > > [...]
                > > >
                > > > However if a try normal m`:%s/find/replace/e'`, only
                > > > the mark part of the command gets done and not the
                > > > :%s . It seems like any Ex commands (:) I specify
                > > > with normal don't seem to work. I must be missing
                > > > something, can anyone help ?
                > >
                > > [...]
                >
                > Ahh ok that works..Thanks. I guess I should have read
                > more carfully.. "If {commands} does not finish a
                > command, the last one will be aborted as if <Esc> or
                > <C-C> was typed"

                I initially found that remark in the docs a little
                misleading as in the default vi-compatible configuration an
                <Esc> on the command line executes ex commands rather than
                aborting them.

                `:norm! :s/foo/bar/^[' works as expected according to
                whether 'cpoptions' contains an x or not, whereas `:norm!
                :s/foo/bar/' is unaffected by 'cpo', though the docs could
                be read as suggesting otherwise.

                Perhaps the docs should simply say that the command is
                aborted and either omit mention of <Esc>, or omit mention of
                both <Esc> and <C-C>. Alternatively 'cpo's lack of effect
                could be pointed out.

                Just a thought.

                Antony
              • Bram Moolenaar
                ... It sometimes does matter how the command is aborted, because it may have an effect on what happens. For the command line CTRL-C is used, thus it doesn t
                Message 7 of 10 , Dec 3, 2004
                • 0 Attachment
                  Antony Scriven wrote:

                  > David Rennalls wrote:
                  >
                  > > [...] Bram Moolenaar <bram@... wrote:
                  > > >
                  > > > David Rennalls wrote:
                  > > >
                  > > > > [...]
                  > > > >
                  > > > > However if a try normal m`:%s/find/replace/e'`, only
                  > > > > the mark part of the command gets done and not the
                  > > > > :%s . It seems like any Ex commands (:) I specify
                  > > > > with normal don't seem to work. I must be missing
                  > > > > something, can anyone help ?
                  > > >
                  > > > [...]
                  > >
                  > > Ahh ok that works..Thanks. I guess I should have read
                  > > more carfully.. "If {commands} does not finish a
                  > > command, the last one will be aborted as if <Esc> or
                  > > <C-C> was typed"
                  >
                  > I initially found that remark in the docs a little
                  > misleading as in the default vi-compatible configuration an
                  > <Esc> on the command line executes ex commands rather than
                  > aborting them.
                  >
                  > `:norm! :s/foo/bar/^[' works as expected according to
                  > whether 'cpoptions' contains an x or not, whereas `:norm!
                  > :s/foo/bar/' is unaffected by 'cpo', though the docs could
                  > be read as suggesting otherwise.
                  >
                  > Perhaps the docs should simply say that the command is
                  > aborted and either omit mention of <Esc>, or omit mention of
                  > both <Esc> and <C-C>. Alternatively 'cpo's lack of effect
                  > could be pointed out.

                  It sometimes does matter how the command is aborted, because it may have
                  an effect on what happens.

                  For the command line CTRL-C is used, thus it doesn't depend on the value
                  of 'cpoptions'. The help clearly says the command is aborted without
                  condition.

                  --
                  ARTHUR: What are you going to do. bleed on me?
                  "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/ \\\
                  \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
                  \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
                • Antony Scriven
                  ... Well, the help says that `{commands} is executed like it is typed. It then says that an incomplete command is aborted `as if ... was typed. For me
                  Message 8 of 10 , Dec 3, 2004
                  • 0 Attachment
                    Bram Moolenaar wrote:

                    > Antony Scriven wrote:
                    >
                    > > David Rennalls wrote:
                    > >
                    > > > [...]
                    > > >
                    > > > Ahh ok that works..Thanks. I guess I should have read
                    > > > more carfully.. "If [:normal] {commands} does not
                    > > > finish a command, the last one will be aborted as if
                    > > > <Esc> or <C-C> was typed"
                    > >
                    > > I initially found that remark in the docs a little
                    > > misleading as in the default vi-compatible configuration an
                    > > <Esc> on the command line executes ex commands rather than
                    > > aborting them.
                    > >
                    > > [...]
                    >
                    > It sometimes does matter how the command is aborted,
                    > because it may have an effect on what happens.
                    >
                    > For the command line CTRL-C is used, thus it doesn't
                    > depend on the value of 'cpoptions'. The help clearly
                    > says the command is aborted without
                    > condition.

                    Well, the help says that `{commands} is executed like it is
                    typed.' It then says that an incomplete command is aborted
                    `as if <Esc> ... was typed.' For me typing escape does not
                    abort a command thus I find the help ambiguous, especially
                    as the default behaviour of vim is to execute a command when
                    hitting escape. But I guess it was just me who got confused
                    by that then. :-)

                    Antony
                  • Bram Moolenaar
                    ... The help text says: If {commands} does not finish a command, the last one will be aborted as if or was typed. Leaving out the or does
                    Message 9 of 10 , Dec 3, 2004
                    • 0 Attachment
                      Antony Scriven wrote:

                      > > It sometimes does matter how the command is aborted,
                      > > because it may have an effect on what happens.
                      > >
                      > > For the command line CTRL-C is used, thus it doesn't
                      > > depend on the value of 'cpoptions'. The help clearly
                      > > says the command is aborted without
                      > > condition.
                      >
                      > Well, the help says that `{commands} is executed like it is
                      > typed.' It then says that an incomplete command is aborted
                      > `as if <Esc> ... was typed.' For me typing escape does not
                      > abort a command thus I find the help ambiguous, especially
                      > as the default behaviour of vim is to execute a command when
                      > hitting escape. But I guess it was just me who got confused
                      > by that then. :-)

                      The help text says:

                      If {commands} does not finish a command, the last one will be
                      aborted as if <Esc> or <C-C> was typed.

                      Leaving out the "or <C-C>" does cause confusion! Which one is used
                      depends on the current mode.

                      --
                      A village. Sound of chanting of Latin canon, punctuated by short, sharp
                      cracks. It comes nearer. We see it is a line of MONKS ala SEVENTH SEAL
                      flagellation scene, chanting and banging themselves on the foreheads with
                      wooden boards.
                      "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/ \\\
                      \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
                      \\\ Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html ///
                    • Antony Scriven
                      ... Ah, so leaving insert mode uses so that abbrevs are triggered, whereas command-line mode uses so that they are not? I still think help text is
                      Message 10 of 10 , Dec 3, 2004
                      • 0 Attachment
                        Bram Moolenaar wrote:

                        > [...]
                        >
                        > The help text says:
                        >
                        > If {commands} does not finish a command, the last one will be
                        > aborted as if <Esc> or <C-C> was typed.
                        >
                        > Leaving out the "or <C-C>" does cause confusion! Which one is used
                        > depends on the current mode.

                        Ah, so leaving insert mode uses <Esc> so that abbrevs are
                        triggered, whereas command-line mode uses <C-C> so that they
                        are not? I still think help text is a little bit vague here :-)

                        Antony
                      Your message has been successfully submitted and would be delivered to recipients shortly.