How to convert _ to \_
Consider using listings
' \lstinline
(experimental):
\documentclass{article}
\usepackage{listings}
\lstset{
basicstyle = \ttfamily
}
\let\code\lstinline
\begin{document}
Some regular text.
Some \code{code} inline.
Then some \code{multiple_words} code word.
\end{document}