I've been using vim for about 3 years and am starting to write my first plugin. I've noticed when looking at the code of other popular plugins that the functions very rarely seem to achieve their aim with lines like:
execute "normal! <some commands>"
Instead opting for usingto use Vim's built in functions. Given the power of Vim's normal mode commands to do so much, what is the general reason for not employing them more often when writing plugins? For example is there a good reason to prefer code (A) or (B) (given that they achieve the same result):
Code (A):
let l = line(".")
let c = col(".")
call search('mysearch')
call setline(line("."), 'better')
call cursor(l, c)
Code (B):
normal! mx
execute "normal! /mysearch/\<CR>"
normal! 0c$better
normal! `x
Code (A) seems a little more readable, and won't clobber the marks (and not the search registers?). Is there a more important reason I'm missing?