How to change highlighted text?

2018-04-19 17:05:05

I write using LaTeX a lot for scientific writing. I often need to modify some text that includes numbers and units like:

4.2 cm



to be properly typeset by LaTeX. Of course, the exact number and unit can change.

I would like to know a "magic" command I can do that—when 4.2 cm is highlighted in visual mode—will change to the \SI{4.2}{cm}.

What is the magic here?