I suspect that's because the search command is saving and restoring
the cursor position.  I was thinking that a way around it would be to
create a once-only autocommand, but I found:

1) BufEnter/WinEnter events aren't called when returning from /,
2) call cursor(1,1) doesn't seem to do what I wanted even when  I
switched windows with  wincmd w
3) I probably don't know the right event to use
4) I probably don't know the right way to define the autocommand



function! TT()
    aug TT
        "
        "au BufEnter * call input('bufenter here' ) | aug TT | au! | aug END | 
aug! TT
        "au winEnter * call input('winenter here' ) | aug TT | au! | aug END | 
aug! TT

        au bufEnter * echomsg 'TT() bufenter'
        au bufEnter * call cursor(1,1)
        au bufEnter * aug TT
        au bufenter * au!
        au bufenter * aug END
        au bufenter * aug! TT

        au winEnter * echomsg 'TT() winenter'
        au bufEnter * call cursor(1,1)
        au winEnter * aug TT
        au winenter * au!
        au winenter * aug END
        au winenter * aug! TT

    aug END
endfunction



On 4/19/06, Hari Krishna Dara <[EMAIL PROTECTED]> wrote:
>
> If you execute a function that changes the cursor position from the
> search prompt, vim completely ignores it, but the same works fine from
> the command prompt. Say, you have something like this:
>
> function! TT()
>   call cursor(1,1)
>   return ""
> endfunction
>
> and you execute it as:
>
> :<C-R>=TT()<CR>
>
> the cursor position gets changed to the start of the file, but the same
> doesn't work if you do the below:
>
> /<C-R>=TT()<CR>
>
> Is this a bug or intended behavior? I can't find a way to get this to
> work without coming out of the search prompt, go into the command
> prompt to execute the function, and return back to the search prompt.
> Any help is apprecaited.
>
> --
> Thanks,
> Hari
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>

Reply via email to