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

134651Re: exec "normal i"

Expand Messages
  • Gary Johnson
    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
    • Show all 6 messages in this topic