Wednesday, June 23, 2010

Why the cursor does not move after I use the autocmd?

Hi,

I use the autocommand in my script:

augroup AutoCmd
autocmd!
au! CursorHold * call g:test()
augroup end


function! g:test()


let l:line = getline(".")

let l:first_space = stridx(l:line," ")+1
let l:second_space=stridx(l:line," ",l:first_space)+1
let l:linenumber = strpart(l:line,l:first_space,l:second_space-
l:first_space-1)
let l:colnumber = strpart(l:line,l:second_space)
let l:fname = strpart(l:line,0,first_space-1)

silent! exe 'belowright pedit ' . l:fname . "\|" . l:linenumber .
"\|" . "normal " . l:colnumber . "\|"
return

endfunction " }}}

The function will parse a line under the cursor with file name and
line and column number, then open the file in the preview window at
the line and column. However, everytime when I switch to the tab page,
the cursor will stop at the first line in the window, I could not move
the cursor using the movement command such as j, k. If I move it use
the mouse, then it will jump back automatically. The cursor is always
at the first line and first column.

Could anyone help me to find out why?

Thank you very much

Frank

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: