[CentOS] Vim scripting - cursor motion

Fri Jun 10 18:42:54 UTC 2011
Les Mikesell <lesmikesell at gmail.com>

On 6/10/2011 1:03 PM, Jussi Hirvi wrote:
> On 10.6.2011 18.39, flapeccino at gmail.com wrote:
>> There is a good article on vimscript here:
>> http://www.ibm.com/developerworks/linux/library/l-vimscript-1/index.html)
>
> Sorry there was a typo, the correct URL is:
> http://www.ibm.com/developerworks/linux/library/l-vim-script-1/index.html
>
> Thanks, I found that already, and it is a good one. But it didn't help
> me solve my problem about cursor motions.
>
> Maybe my question is wrong - maybe I should just use line ranges in
> commands, for example for the first line:
> 	:1,1s/foo/bar/g
> and for the last line:
> 	:$,$s/foo/bar/g

I thought the point of using vim instead of something more appropriate 
for scripting was that you already knew how to use it.  Why not do:
vim -W script testfile
and go through the motions you know (which can include 1G to go to the 
1st line and G to go to the last).
Then run
vim -s script realfile
to do the same actions again.

-- 
   Les Mikesell
    lesmikesell at gmail.com