<div>Jussi</div>
<div> </div>
<div>I tried various ways but it seems the only way to insert a line from a script is to use the append() function  (do help append) specifying the line number as a parameter. </div>
<div> </div>
<div>I tried it on with an example script "moo.vim" as shown below</div>
<div> </div>
<div><a href="mailto:flapeccino@T4410" target="_blank">flapeccino@T4410</a> ~<br>$ cat moo.vim<br>:1,$s/  /,/g<br>:call append(0,"This is the first line")<br>:call append(line('$'),"This is the last line")<br>
:w foox<br>:q!</div>
<div><a href="mailto:flapeccino@T4410" target="_blank">flapeccino@T4410</a> ~<br>$ cat foo<br>one     two     three   four<br>1       2       3       4<br>ichi    ni      san     shi</div>
<div><a href="mailto:flapeccino@T4410" target="_blank">flapeccino@T4410</a> ~<br>$ vi -s moo.vim foo</div>
<div><a href="mailto:flapeccino@T4410" target="_blank">flapeccino@T4410</a> ~<br>$ cat foox<br>This is the first line<br>one,two,three,four<br>1,2,3,4<br>ichi,ni,san,shi<br>This is the last line</div>
<div><a href="mailto:flapeccino@T4410" target="_blank">flapeccino@T4410</a> ~</div>
<div> </div>
<div><br>BTW thank you for this, I have been using vi for a very long time, and I never realized until now that  at least in its vim incarnation it has such a powerful scripting language.  I've used sed/awk/perl but never happily and always felt an inferiority complex to the emac brethrens showing off with their emac lisp macros.  It must be a deficiency but my fingers never could do emacs.</div>

<div> </div>
<div> </div>
<div> </div>
<div class="gmail_quote">On Fri, Jun 10, 2011 at 11:42 AM, Les Mikesell <span dir="ltr"><<a href="mailto:lesmikesell@gmail.com" target="_blank">lesmikesell@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>On 6/10/2011 1:03 PM, Jussi Hirvi wrote:<br>> On 10.6.2011 18.39, <a href="mailto:flapeccino@gmail.com" target="_blank">flapeccino@gmail.com</a> wrote:<br>>> There is a good article on vimscript here:<br>>> <a href="http://www.ibm.com/developerworks/linux/library/l-vimscript-1/index.html" target="_blank">http://www.ibm.com/developerworks/linux/library/l-vimscript-1/index.html</a>)<br>
><br>> Sorry there was a typo, the correct URL is:<br>> <a href="http://www.ibm.com/developerworks/linux/library/l-vim-script-1/index.html" target="_blank">http://www.ibm.com/developerworks/linux/library/l-vim-script-1/index.html</a><br>
><br>> Thanks, I found that already, and it is a good one. But it didn't help<br>> me solve my problem about cursor motions.<br>><br>> Maybe my question is wrong - maybe I should just use line ranges in<br>
> commands, for example for the first line:<br>>       :1,1s/foo/bar/g<br>> and for the last line:<br>>       :$,$s/foo/bar/g<br><br></div>I thought the point of using vim instead of something more appropriate<br>
for scripting was that you already knew how to use it.  Why not do:<br>vim -W script testfile<br>and go through the motions you know (which can include 1G to go to the<br>1st line and G to go to the last).<br>Then run<br>
vim -s script realfile<br>to do the same actions again.<br><font color="#888888"><br>--<br>  Les Mikesell<br>   <a href="mailto:lesmikesell@gmail.com" target="_blank">lesmikesell@gmail.com</a><br></font>
<div>
<div></div>
<div>_______________________________________________<br>CentOS mailing list<br><a href="mailto:CentOS@centos.org" target="_blank">CentOS@centos.org</a><br><a href="http://lists.centos.org/mailman/listinfo/centos" target="_blank">http://lists.centos.org/mailman/listinfo/centos</a><br>
</div></div></blockquote></div><br>