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

Re: exec "normal i"

Expand Messages
  • oversky
    In the document, it says When the ! is included it works like A , append to the line. is it possible to make it works like a , so the cursor stay in the
    Message 1 of 6 , Nov 20, 2012
    • 0 Attachment
      In the document, it says

      When the ! is included it works like "A", append to the line.

      is it possible to make it works like "a", so the cursor stay in the
      current position?


      On 11月21日, 下午1時58分, Gary Johnson <garyj...@...> wrote:
      > On 2012-11-20, oversky wrote:
      > > I want a function ending in the insert mode.
      > > However,  exec "normal i" or exec "normal a" keeps staying in the
      > > normal mode.
      > > Is it possible to do what I want?
      >
      >     :help :startinsert
      >
      > Regards,
      > Gary

      --
      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
    • Gary Johnson
      ... You could move the cursor to the right before executing ... normal l startinsert Regards, Gary -- You received this message from the vim_use maillist. Do
      Message 2 of 6 , Nov 21, 2012
      • 0 Attachment
        On 2012-11-20, oversky wrote:

        > On 11月21日, 下午1時58分, Gary Johnson <garyj...@...> wrote:
        > > On 2012-11-20, oversky wrote:
        > > > I want a function ending in the insert mode.
        > > > However,  exec "normal i" or exec "normal a" keeps staying in the
        > > > normal mode.
        > > > Is it possible to do what I want?
        > >
        > >     :help :startinsert

        > In the document, it says
        >
        > When the ! is included it works like "A", append to the line.
        >
        > is it possible to make it works like "a", so the cursor stay in the
        > current position?

        You could move the cursor to the right before executing
        :startinsert, like this:

        normal l
        startinsert

        Regards,
        Gary

        --
        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
      • oversky
        ... Thanks, Gary. I found that when the cursor is at the end of a line, vim can t move the cursor right. So the result is still insert but not append. I am
        Message 3 of 6 , Nov 21, 2012
        • 0 Attachment
          On Wednesday, November 21, 2012 4:48:56 PM UTC+8, Gary Johnson wrote:
          > You could move the cursor to the right before executing
          >
          > :startinsert, like this:
          >
          > normal l
          >
          > startinsert
          >
          > Regards,
          >
          > Gary
          Thanks, Gary.
          I found that when the cursor is at the end of a line,
          vim can't move the cursor right.
          So the result is still insert but not append.
          I am using ve=all as a temporary solution,
          Do you have more suggestion to make it work in ve= never.

          --
          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
        • Gary Johnson
          ... I think the usual solution to that problem is set ve=onemore However, if you are writing a script you have a lot more flexibility in the solution since a
          Message 4 of 6 , Nov 22, 2012
          • 0 Attachment
            On 2012-11-21, oversky wrote:
            > On Wednesday, November 21, 2012 4:48:56 PM UTC+8, Gary Johnson wrote:
            > > You could move the cursor to the right before executing
            > > :startinsert, like this:
            > >
            > > normal l
            > > startinsert

            > Thanks, Gary.
            > I found that when the cursor is at the end of a line,
            > vim can't move the cursor right.
            > So the result is still insert but not append.
            > I am using ve=all as a temporary solution,
            > Do you have more suggestion to make it work in ve= never.

            I think the usual solution to that problem is

            set ve=onemore

            However, if you are writing a script you have a lot more flexibility
            in the solution since a script can contain relatively complex code.
            A script can determine the current cursor position and whether the
            cursor is at the beginning, end or elsewhere in the line, then
            choose its behavior accordingly. So you could put something like
            this in your script (untested):

            if col(".") == col("$")-1
            " Cursor is at the end of the line.
            startinsert!
            else
            " Cursor is not at the end of the line.
            normal l
            startinsert
            endif

            HTH,
            Gary

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