JSFiddle - React, Tailwind, and code Playground

HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<textarea id="texto" rows="10" style="width: 100%;"></textarea>
<div id="editor" style="width:100%; height:800px;background: #eee;">

</div>

JavaScript

$("#editor").click(function() {
  $("#texto").focus();
});
$("#texto").keyup(function() {
  var texto = $("#texto").val();
  var sub = texto.replace(/(\$|(var))/g,'<u style="color: red;">$1</u>');
  $("#editor").html(sub);
});