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

28063Re: Set the cursor position in vim functions

Expand Messages
  • Brett Pershing Stahlman
    May 1, 2002
      Francois,
      The reason that
      :exec lineno
      worked is that when in ex mode (command-line mode), a command consisting of
      a single number means go to the line indicated by the number. All lines in a
      vim script represent commands executed on the command line, so if you want
      to do a normal mode command -
      e.g., N|, to go to column N from within a vim script, you have to tell vim
      that the keystrokes are to be executed in normal mode rather than ex mode.
      The way you do this is to use the normal command.
      e.g., to go to column 10, you would type

      :normal 10|

      Since the arguments to "normal" command are taken literally (i.e., no
      variable substitution takes place), you must build up the normal command as
      a string that can be passed to execute command if the column position is a
      variable.
      e.g.,
      :let str = "normal " . col . '|'
      :execute str

      or, to do it in one line,
      :execute "normal " . col . '|'

      Hope this helps explain it...

      Brett S.

      ----- Original Message -----
      From: Francois Desarmenien <francois@...>
      To: Gary Holloway <gary@...>
      Cc: <vim@...>
      Sent: Wednesday, May 01, 2002 4:22 AM
      Subject: Re: Set the cursor position in vim functions


      Le Tue, 30 Apr 2002 12:35:39 -0700
      gary@... (Gary Holloway) a ecrit:

      > Try
      >
      > exe 'normal ' . column . '|'

      I was just missing the "normal " prepended, but
      still wonder what does it stands for...

      Many thanks,

      Fran├žois
    • Show all 10 messages in this topic