I'm trying to write a opfunc which surrounds selected motion with two stars (bold in Markdown):
nnoremap <localleader>b :set opfunc=BoldIt<CR>g@
function! BoldIt(type, ...)
execute "normal! `[i**"
execute "normal! `]a**"
endfunction
According to :map-operator
info:
[
mark denotes start of text]
mark denotes end of text
In my function just one of the marks works. I mean, if I comment either of the execute
lines, the other one does the job correctly, as supposed to.
However, when run as shown, stars end in the same position. It's just like if one of the mark get lost. What I'm missing?