:map ,bb c<CR><CR><ESC>kpI<span><ESC>A</span><ESC>kJJ
Any thoughts on why this only works sometimes? I can't isolate
what conditions bring it about.
What are the results when it "doesn't work"?
It looks like you're actually rejoining the lines, so it's odd to
add the <CR>s just to remove them.
Other items include using ":map" instead of "vnoremap" which
isolates the mapping to visual mode. My first take on the matter
would be something like
:vnoremap ,bb c<span><c-r>"</span><esc>
If this has funky indenting problems (commonly called "marching
indent"), you can use this more complex
:vnoremap ,bb c<span><c-o>:let b:old_paste=&paste<bar>set
paste<cr><c-r>"<c-o>:let &paste=b:old_paste<cr></span><esc>
which preserves the 'paste' option, sets the paste option, does
the pasting, and then restores your original paste option. If it
was really well behaved, it would even delete the variable for
you afterwards. :)
You can read more about this stunt at
:help i_CTRL-R
which pastes
-tim