The following operator-depending mapping works great for me,
onoremap <silent> a$ :<C-U>normal! hEF$v,<CR>
except when it is issued at the very beginning of a line. What happens is that the
h raises an error despite the preceding
<silent> and the whole mapping gets canceled nonetheless.
With an operator-depending mapping, how can such a trivial bordercase error be silenced or ignored?
Here is a line to test it on:
$E = mc^2$ this is a test line with inline $\LaTeX$ math $\Omega$
At the end of the day, I solved the original problem with a different mapping:
onoremap <expr> a$ col('.') >= (col('$') - 1) && getline('.') == '$' ? ':<C-U>normal! Bf$v,<CR>' : ':<C-U>normal! wBf$v,<CR>'