[CentOS] Vim scripting - cursor motion
Kahlil Hodgson
kahlil.hodgson at dealmax.com.au
Tue Jun 14 01:41:47 UTC 2011
On 11/06/11 19:03, Jussi Hirvi wrote:
> Ok, that helped me along. For some reason the motions (like 1G0 for
> beginning of file, or G$ for last char in file) work, when the script is
> called from command-line with -s flag (vim -s myscript myfile). But they
> don't work when the script is called from inside vim (:source myscript).
> I wonder why.
Try adding :normal to every 'key stroke' command, i.e.,
> :% s/\t/","/g
> :% s/\r\n/\r/g
> :% s/\n/"),\r("/g
> :normal 1G0I("^[
> :normal Gdd
> :normal G$xa;^[
> :w
off the top of my head, that should then work in both scenarios (not
tested).
Yes, vim scripting is a bit weird, nowhere near as elegant as emacs
lisp, but it does get the job done if you have the patience.
For debugging try the online help
:h debug-scripts
Happy Hacking!
Kal
More information about the CentOS
mailing list