I'd count the number of space characters before the cursor at the moment <cr>
is hit and produce as many <BS>
. It can be done with substitute also:
:inoremap <expr> <cr> substitute(matchstr(getline('.')[: col('.')-2], '\s*$'), '.', "<bs>", 'g')."<cr>"
or
:inoremap <expr> <cr> repeat("<bs>", len(matchstr(getline('.')[: col('.')-2], '\s*$')))."<cr>"