Re: Set the cursor position in vim functions
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...
- Le Wed, 1 May 2002 08:36:07 -0500
"Brett Pershing Stahlman" <brett.stahlman@...> a ecrit:
> Hope this helps explain it...Yes, it does: now I begin to catch a glimpse of the vim programming
philosophy which is quite disconcerting at first sight... as is its
huge documentation, without any critisism in mind.
Many thanks for your time and patience, to you and all the others
from the list, too.