i have a function, e.g. Replace(len), used for:
:map \z <c-r>=Replace(10)<cr>

this function will delete last 10 letters in the buffer, and replace
it to register z:
function Replace1(len)
    let len = a:len <= 1 ? '' : (a:len - 1).'h'
    return "\<esc>v".len."\"zpa"
endfunction

it works very well. however, i still have a lot of work to do in this
function, so i changed the way:
function Replace2(len)
    " other normal command....
    exec 'norm! v'.(a:len <= 1 ? '' : (a:len - 1).'h').'"zpa'
    return ''
endfunction

but it can't work when i use it in <c-r>, when i use it as :call
Replace(10). it works very well, but when it used in <c-r>=Replace(10)
in insert mode, it only delete 9 letters, and the cursor is in a wrong
position, too.

e.g:, there are"1234567890abcd|" in the buffer, "|" stands for cursor.
and z register is "zzzz"
if you do:
:exec "norm! ".Replace1(10)<cr>
a<c-r>=Replace1(10)<cr>
:call Replace2(20)<cr>
the result is the same:
123zzzz|

but, if you do:
a<c-r>=Replace2(10)<cr>
the result is:
1234zzz|z

anyone have any idea? i use Vim7.2....
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to