in my plugin, i am joining XML tags together depending on a mapping a use. It also uses so i can make XML snippets repetitive. After inserting the text into a buffer, i would like the cursor to return to the initial position from which I started the 'pasting', but somehow i cannot leave the insert mode.
The function looks like this:
function s:DocbkPrintTag(tag)
"mark the initial position
execute "normal! mq"
let result = repeat(s:DocbkRenderTag(a:tag), v:count1)
if !empty(result)
call feedkeys('a' . result, 'n')
endif
"stop insert mode and resore the cursor position
execute "normal! `q"
endfunction