Solution to pasting text with italics (underscore vs. asterisk)

Continuing the discussion from When pasting something into Obsidian, can I set which version of the italicizing marks are used?:


I finally found a solution! Using the Shell Commands Plugin you can create a new command, then in the settings choose the Event Switching the active pane, and then put this in the text field for the command:

sed -i -e 's/_\([a-zA-Z0-9]*\)_/*\1*/g' {{file_path:absolute}}

So if you now paste text that has italics and Obsidian converts those to _underscore italics_ but you’d rather have *asterisks* this command switches that whenever you change the pane focus TO that particular note. So if you’re impatient, you can click into another note and then back. Or it just does it automatically the next time anyways.

And this should only change those underscores surrounded by spaces or periods, commas, so URLs should be safe, but use at your own risk.