I’m mostly using obsidian for coding notes and some variable names takes underscore
You should use inline code to mention variable names and other parts of code or verbatim content in text:
Set variable `foo_bar_baz` to 1.
which will render in reading view as
Set variable foo_bar_baz to 1.