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

Re: :normal stops execution when cursor can't be moved

Expand Messages
  • Ingo Karkat
    ... When you type this manually, you re effectively executing this: execute norm! dd | execute norm! k | execute norm! P And this indeed doesn t stop.
    Message 1 of 4 , Jan 6, 2013
    View Source
    • 0 Attachment
      On 04-Jan-13 12:58:15 +0900, Mohammed Chelouti wrote:

      > Hello
      >
      > I have found an unexpected behaviour in the normal command and I am not sure
      > if it is a bug or just not explicitly mentioned in the help.
      >
      > Consider the following file (# depicts the cursor):
      >
      > 1 foo
      > 2 #bar
      > 3 zab
      >
      > Now enter :norm! ddkP, the file should now look like this.
      >
      > 1 #bar
      > 2 foo
      > 3 zab
      >
      > So far so good, execute the same command once more. Result:
      >
      > 1 #foo
      > 2 zab
      >
      > The first line was removed but not inserted; this doesn't happen when
      > executing ddkP manually.

      When you type this manually, you're effectively executing this:

      execute 'norm! dd' | execute 'norm! k' | execute 'norm! P'

      And this indeed doesn't stop.

      > The help file says that :normal stops on errors but is it an error
      > when the cursor just can't move one line up?

      Yes it is. The beep that is issued is a clear indication of the error.

      > I don't know what behaviour was intended, but I think it should either
      > be considered a bug or there should be an explicit hint in the help.

      Yes, it is intended, and it's very helpful to abort (recursive) macros. And the
      reference in the help is exactly what you've quoted. Sorry that some Vim
      peculiarities are so hard to discover, but I guess that's the price one has to
      pay for such a powerful editor.

      -- 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
    • Andy Wokula
      ... And one more hint in the help is ... it applies because arguments from :normal are like arguments from a mapping (although :h :normal says {commands} are
      Message 2 of 4 , Jan 7, 2013
      View Source
      • 0 Attachment
        Am 07.01.2013 01:39, schrieb Ingo Karkat:
        > On 04-Jan-13 12:58:15 +0900, Mohammed Chelouti wrote:
        >
        >> Hello
        >>
        >> I have found an unexpected behaviour in the normal command and I am
        >> not sure if it is a bug or just not explicitly mentioned in the help.
        >>
        >> Consider the following file (# depicts the cursor):
        >>
        >> 1 foo
        >> 2 #bar
        >> 3 zab
        >>
        >> Now enter :norm! ddkP, the file should now look like this.
        >>
        >> 1 #bar
        >> 2 foo
        >> 3 zab
        >>
        >> So far so good, execute the same command once more. Result:
        >>
        >> 1 #foo
        >> 2 zab
        >>
        >> The first line was removed but not inserted; this doesn't happen when
        >> executing ddkP manually.
        >
        > When you type this manually, you're effectively executing this:
        >
        > execute 'norm! dd' | execute 'norm! k' | execute 'norm! P'
        >
        > And this indeed doesn't stop.
        >
        >> The help file says that :normal stops on errors but is it an error
        >> when the cursor just can't move one line up?
        >
        > Yes it is. The beep that is issued is a clear indication of the error.
        >
        >> I don't know what behaviour was intended, but I think it should either
        >> be considered a bug or there should be an explicit hint in the help.
        >
        > Yes, it is intended, and it's very helpful to abort (recursive)
        > macros. And the reference in the help is exactly what you've quoted.
        > Sorry that some Vim peculiarities are so hard to discover, but I guess
        > that's the price one has to pay for such a powerful editor.

        And one more hint in the help is
        :h map_return

        it applies because arguments from :normal are like arguments from a
        mapping (although :h :normal says "{commands} are executed like they are
        typed." ... which is a bit misleading (it should say "{commands} are
        executed like coming from a mapping"))

        There is one weird detail though:
        Without [!], :normal continues.
        Same for a mapping for which remapping is allowed: it continues
        after the error.
        I actually didn't notice this before.

        --
        Andy

        --
        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
      • Mohammed Chelouti
        ... Apparently my speakers are disabled and visualbell is not set. That explains why I was confused by the lack of feedback. :) Thanks for clarifying that.
        Message 3 of 4 , Jan 7, 2013
        View Source
        • 0 Attachment
          On Monday 07 January 2013 09:39:18 Ingo Karkat wrote:
          > Yes it is. The beep that is issued is a clear indication of the error.

          Apparently my speakers are disabled and visualbell is not set. That explains
          why I was confused by the lack of feedback. :)

          Thanks for clarifying that.

          Best regards,
          Mohammed

          --
          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
        Your message has been successfully submitted and would be delivered to recipients shortly.