On Mar 11, 5:13 am, Matt Wozniski <[email protected]> wrote:
> On Tue, Mar 10, 2009 at 6:32 PM, RPN wrote:
> for l in range(s+1,e)
> let atom = matchstr(getline(l),'\w\+')
> exec 'hi link L'.(l-s).' '.atom
> endfor
> endfun
> call Update()
>
> It's exactly the same issue - your syntax highlighting script moves the
> cursor.
>
> ^ search() moves the cursor unless you give it the 'n' flag!
Thanks for the info Matt. I think I have solved it now. I tried just
adding the 'n' flag to both my searches. But that screws up the
program logic. I think the way it was written it actually depends on
the cursor moving to where it does after the search is done.
Then I added two lines to save and restore the cursor position around
the body of the Update position. That seems to do the trick (unless
there is something that I still miss and haven't yet discovered!).
##########################
func! Update()
let save_cursor = getpos(".")
let s = search('^ DynamicAtomSpecies =','w')
let e = search(';')
[function cruft]
call setpos('.', save_cursor)
endfun
#############################
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---