The reason that
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
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
:let str = "normal " . col . '|'
or, to do it in one line,
:execute "normal " . col . '|'
Hope this helps explain it...
----- Original Message -----
From: Francois Desarmenien <francois@...>
To: Gary Holloway <gary@...>
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:
> exe 'normal ' . column . '|'
I was just missing the "normal " prepended, but
still wonder what does it stands for...