Re: Vim scripting - cursor motion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



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
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos


[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux